npm.io
1.0.1 • Published 8 years ago

dambreaker-mongo

Licence
MIT
Version
1.0.1
Deps
4
Size
311 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

dambreaker-mongo

Mongo service for dambreaker.

NPM Build Status Coverage Status

Features

return $mongo.db.then(db => {
  //db is a singleton Mongo Db instance
});

Add the mongo connection string in dambreaker.json

{
	"mongo": {
        "connectionString": "mongodb://localhost:27017/database"
    },
}
Inject the dambreaker mongo service
{
  "services": [
    { "name": "mongo", "location": "dambreaker-mongo" }
  ]
}

Or in javascript

const DamBreaker = require("dambreaker");
const dambreaker = new DamBreaker();
dambreaker.inject("mongo" ,"dambreaker-mongo");
Use REST api

class Api {
    constructor(mongo) {    //mongo service is injected by dambreaker DI
        super("<collectionName>", mongo);
    };
Override the default behaviour
const { CRUD } = require("dambreaker-mongo");

class Api extends CRUD {
  constructor(mongo) {
    this.mongo = mongo;
  };
};

Installation

$ npm install dambreaker-mongo

Test

To run our tests, clone the dambreaker-mongo repo and install the dependencies.

$ git clone https://github.com/BenoitClaveau/dambreaker-mongo --depth 1
$ cd dambreaker-mongo
$ npm install
$ mongod --dbpath ./data/db
$ node.exe "../node_modules/mocha/bin/mocha" tests

Keywords