node.js - node-mongodb-native 2.X driver using to multiple databases -


is there way use multiple databases single connection mongodb? i've found this:

https://mongodb.github.io/node-mongodb-native/api-generated/mongoclient.html#open

but best can tell docs old there not appear open method on mongoclient? need establish multiple connections?

thanks!

found it:

http://mongodb.github.io/node-mongodb-native/2.0/api/db.html#db

here example

var mongoclient = require('mongodb').mongoclient,   test = require('assert'); mongoclient.connect('mongodb://localhost:27017/test', function(err, db) {   test.equal(null, err);    // reference different database sharing same connections   // data transfer   var seconddb = db.db("integration_tests_2");   ... 

it synchronous. seems strange me method doesn't have word "use" in it. seems strange belongs db class. db.db('other_db').. bit obscure. did tests, seems work, i'll mark answer else ends here.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -