🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

app-context-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-context-mongodb

MongoDB initializer for app-context

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

app-context-mongodb

MongoDB initializer for app-context

Usage

This initializer can be auto-installed by using it in your context file.

This initializer will attach the configured connections to APP.mongodb.

module.exports = function() {
  this.runlevel('connected')
    // attach a connection to APP.mongodb - use the value at APP.config.mongodb as the connection string
    .use('mongodb', '$mongodb')

    // attach a connection to APP.mongodb
    .use('mongodb', 'mongodb://localhost/foobar')

    // create 2 connections and attach them as an object to APP.mongodb
    // this will create APP.mongodb.users and APP.mongodb.data
    .use('mongodb', {
      users: '$mongodb.users',
      data: '$mongodb.data'
    })

    // you can also pass options to each connection
    // (from http://mongodb.github.io/node-mongodb-native/2.0/api/MongoClient.html#.connect)
    .use('mongodb', {
      users: {url: '$mongodb.users', db: {
        wtimeout: 2000,
        authSource: 'other-db'
      }},
      data: {url: 'mongodb://localhost/data', server: {
        reconnectTries: 2,
        reconnectInterval: 500
      }}
    })
};

Connection Strings

Connection string formats and options are available in the mongodb driver docs.

Connection Configurations

Each connection can be configured with either a connection string (like mongodb://localhost/foobar) or with an object. The object will be passed through to MongoClient.connect and can consist of any options from the mongodb driver. There is a special url option that this initializer requires.

Keywords

app-context

FAQs

Package last updated on 09 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts