Last active
April 18, 2018 00:53
-
-
Save mcshakes/1e3e0ac9ef8094dac2b00ce3a5aed799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Find All | |
db.restaurants.find() | |
2)Limit and Sort | |
db.restaurants.find().sort({'name': 1}).limit(10) | |
3)Find by Object ID | |
db.restaurants.find(ObjectId("59074c7c057aaffaafb0da6d")) | |
4) Get by Value | |
db.restaurants.find({ borough: "Queens" }) | |
5) Count | |
db.restaurants.count() | |
6) Find by nested value: | |
db.restaurants.find({ "address.zipcode": "11206" }).count() | |
7)Delete by ID | |
db.restaurants.deleteOne({ _id: ObjectId("59074c7c057aaffaafb11cb2")}) | |
8) Update | |
db.restaurants.update({ | |
... _id: ObjectId("59074c7c057aaffaafb11c28") | |
... },{ | |
... name: "Poop Chute" | |
... }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment