hapi-mongodb-profiles

2.0.2 • Public • Published

hapi-mongodb-profiles

Simple hapi plugin to manage mongodb connection profiles

Build Status Dependency Status

Register plugin

server.pack.register({
    plugin: require('hapi-mongodb-profiles'),
    options: {
        // decorateRequest: false // default: true
        options: {
            // default options for all profiles, will be extended by local profile options
        }
        profiles: [
            { name: 'test', url: 'hapi://test/db', options: {
                // local profile options
            }}
        ]
    }
}

Get database

server.plugins['hapi-mongodb-profiles'].db('profileName')
request.db('profileName')
request.db() // first database/profile will be returned

Get collection

server.plugins['hapi-mongodb-profiles'].collection('profileName', 'collectionName')
request.collection('test') // first database/profile will be used
request.collection('profile', 'test')

Readme

Keywords

Package Sidebar

Install

npm i hapi-mongodb-profiles

Weekly Downloads

1

Version

2.0.2

License

MIT

Last publish

Collaborators

  • z0mt3c