Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sys = require("sys");
- var mongodb = require("../lib/mongodb");
- var mongo = new mongodb.MongoDB();
- mongo.addListener("close", function () {
- sys.puts("Closing connection!");
- });
- mongo.addListener("connection", function () {
- var widgets = mongo.getCollection('mycollection');
- console.log((new Date()).getTime() + " A");
- var oId = new mongodb.ObjectID("4cda9e1a8fea02b23e000019");
- console.log(sys.inspect(oId.toString()));
- widgets.find({ fromId: oId, status: 2 }, null, function (results) {
- console.log((new Date()).getTime() + " B");
- // console.log(sys.inspect(results));
- sys.puts("there are " + results.length + " results");
- // close the connection
- mongo.close();
- });
- });
- mongo.connect({
- hostname: '127.0.0.1',
- port: 27017,
- db: 'MyDatabase'
- });
Add Comment
Please, Sign In to add comment