daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Aug 17th, 2018 54 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Get all           db.restaurants.find({});
  2. limit & sort      db.restaurants.find().sort({name: 1}).limit(10);
  3. get by_id         var objectId = db.restaurants.findOne({}, {_id: true})._id;
  4.                   db.restaurants.findOne({_id: objectId});
  5. get by value      db.restaurants.find({borough: "Queens"});
  6. count             db.restaurants.count();
  7. count by
  8. nested value      db.restaurants.find({"address.zipcode": "11206"}).count();
  9. delete by id      var objectId = db.restaurants.findOne({}, {_id: true})._id;
  10.                   db.restaurants.removeOne({_id: objectId});
  11. update 1 doc      var objectId = db.restaurants.findOne({}, {_id: true})._id;
  12.                   db.restaurants.updateOne({_id: objectId}, {$set: {name: "Bizz Bar Bang"}});
  13. update many       db.restaurants.updateMany({"address.zipcode": "10035"}, {$set: {"address.zipcode": "10036"}});
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top