Guest User

Untitled

a guest
Jul 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. var sys = require("sys");
  2. var mongodb = require("../lib/mongodb");
  3.  
  4. var mongo = new mongodb.MongoDB();
  5.  
  6. mongo.addListener("close", function () {
  7. sys.puts("Closing connection!");
  8. });
  9.  
  10. mongo.addListener("connection", function () {
  11. var widgets = mongo.getCollection('mycollection');
  12.  
  13. console.log((new Date()).getTime() + " A");
  14. var oId = new mongodb.ObjectID("4cda9e1a8fea02b23e000019");
  15.  
  16. console.log(sys.inspect(oId.toString()));
  17. widgets.find({ fromId: oId, status: 2 }, null, function (results) {
  18. console.log((new Date()).getTime() + " B");
  19. // console.log(sys.inspect(results));
  20. sys.puts("there are " + results.length + " results");
  21. // close the connection
  22. mongo.close();
  23. });
  24. });
  25.  
  26. mongo.connect({
  27. hostname: '127.0.0.1',
  28. port: 27017,
  29. db: 'MyDatabase'
  30. });
Add Comment
Please, Sign In to add comment