2.2.0 • Published 7 years ago

@terrajs/mono-mongodb v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

mono-mongodb

MongoDB module for Mono.

npm version Travis Coverage license

Installation

npm install --save @terrajs/mono-mongodb

Then, in your configuration file of your Mono application (example: conf/application.js):

module.exports = {
  mono: {
    modules: ['@terrajs/mono-mongodb']
  }
}

Configuration

Mono-MongoDB will use the mongodb property of your configuration (example: conf/development.js):

module.exports = {
  mono: {
    mongodb: {
      url: 'mongodb://localhost:27017/my-db',
      dropDatabase: true //Drop database at launch
      // options property is optional
      options: {
        // See http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect
      }
    }
  }
}

You can set mongodb.dropDatabase: true to drop the database when connected (useful for tests).

Usage

In your modules files, you can access db instance and oid(id) helper like this:

const { db, oid } = require('@terrajs/mono-mongodb')

const users = db.collection('users')

users.findOne({ _id: oid('554ab...' }))
2.2.0

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago