README
hapi-mongodb-profiles
Simple hapi plugin to manage mongodb connection profiles
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')