pongo
Version:
Connection pooling for node-mongodb-native
49 lines (36 loc) • 1.42 kB
Markdown
pongo
=====
Connection pooling for [node-mongodb-native](https://github.com/mongodb/node-mongodb-native).
No more sockets are opened, as defined in the server.poolSize option.
[](https://github.com/mongodb/node-mongodb-native)
npm install pongo
var Pongo = require('pongo');
var pongo = new Pongo({
// mongodb connection
host: "127.0.0.1",
port: 27017,
// maximal number of callbacks that are buffered, while a connection is established to mongodb.
// increase the number, if you get the error message: "Number of callbacks in buffer exceeded".
bufferSize: 100,
// list of valid server options:
// http://mongodb.github.com/node-mongodb-native/api-generated/server.html?highlight=server#server
server: {
poolSize: 3
},
// list of valid db options:
// http://mongodb.github.com/node-mongodb-native/api-generated/db.html?highlight=db#db
db: {
w: 1
}
});
pongo.connect('myMongoDb', function (err, db) {
// use the db instance as you would with the node-mongodb-native driver.
});
pongo.connect('myOtherMongoDb', function (err, db) {
// use the db instance as you would with the node-mongodb-native driver.
});
MIT