Skip to content

Instantly share code, notes, and snippets.

@scottiedog45
Created November 13, 2017 16:25
Show Gist options
  • Save scottiedog45/b94fd5d4ff523c5e3a8b2e3b037a830d to your computer and use it in GitHub Desktop.
Save scottiedog45/b94fd5d4ff523c5e3a8b2e3b037a830d to your computer and use it in GitHub Desktop.
run mongo shell
db.restaurant.find();
db.restaurants.
find().
sort({name:1}).
limit(10);
var documentId = ObjectId('xxxxx');
db.restaurants.findOne({_id: documentId});
db.restaurants.find({bourough: "Queens"});
db.collection.count();
db.collection.find({'address.zipcode': "11206"}).count;
var documentId = ObjectId('xxxxx');
db.restaurants.findOne({}, {_id: documentId})._id;
db.restaurants.removeOne(_id:documentId)
db.restaurants.updateOne(
{_id: documentId},
{$set:{name: "Bizz Bar Bang"}}
);
db.restaurants.updateMany(
{'address.zipcode': "10035"},
{$set:{'address.zipcode': "10036"}}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment