How to manage multiple connections? I don't get it. What is the pool size? I want to use the same connection for all databases, how can I do that?
var db = mongoq('mongodb://localhost/db1') // new connection
var db2 = mongoq('db2') // new connection or the same as above?
Hi, mongoq method will create new connection for db. It has not any public method for db with the same server(connection) now. You can create new connection like your sample. If you find that to do any inconvenience, Please provide examples, I will consider to fix it in the next version.
The pool size said that it will specify more connections in the pool to handle a large number of requests. You can find more docs in node-mongodb-native.
It's useless that way. I want to reuse the same connection or I will keep creating new ones when I try to select a database!
Please tell me how to create a single connection and use multiple databases.
var server = new mongoq.mongodb.Server('localhost', 27017);
var db1 = new mongoq.db("db1", server);
var db2 = new mongoq.db("db2", server);
Right, might be useful some documentation! ...
getting the following error...
throw new Error("A Server or ReplSetServers instance cannot be shared acro
Error: A Server or ReplSetServers instance cannot be shared across multiple Db instances
at new Db (/disk2/var/www/admin.nsmetrics.com/application/scripts/node_modules/mongoq/node_modules/mongodb/lib/mongodb/db.js:74:11)
at new db (/disk2/var/www/admin.nsmetrics.com/application/scripts/node_modules/mongoq/lib/db.js:45:18)
at Object.twelections (/disk2/var/www/admin.nsmetrics.com/application/scripts/gnip-stream.js:218:14)
at Array.forEach (native)
at Object.forEach (/disk2/var/www/admin.nsmetrics.com/application/scripts/node_modules/async/lib/async.js:85:9)
at Object.parallel (/disk2/var/www/admin.nsmetrics.com/application/scripts/node_modules/async/lib/async.js:466:19)
at Object._getExternalRules (/disk2/var/www/admin.nsmetrics.com/application/scripts/gnip-stream.js:189:9)
At first, MongoQ depends on onde-mongodb-native.
It said that node-mongodb-native can't support multiple Db with the same server(connection).
It seems that you have to create two server to deal with the two databases...
Like your first example:
var db1 = mongoq('mongodb://localhost/db1')
var db2 = mongoq('mongodb://localhost/db2')