Last active
May 11, 2018 20:41
-
-
Save FrancesFisk/50179a9d010b49b067c0e420a2ec414d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Get all | |
| db.restaurants.find(); | |
| Limit and sort: | |
| db.restaurants. | |
| ... find(). | |
| ... sort({name: 1}). | |
| ... limit(5); | |
| Get by _id: | |
| db.restaurants.findOne({_id: ObjectId("59074c7c057aaffaafb10c04")}); | |
| Get by value: | |
| db.restaurants.find({borough: "Queens"}); | |
| Count: | |
| db.restaurants.count(); | |
| Count by nested value: | |
| db.restaurants.find({"address.zipcode": "11206"}).count(); | |
| Delete by id: | |
| db.restaurants.deleteOne({_id: ObjectId("59074c7c057aaffaafb0dbb7")}); | |
| Update a single document | |
| db.restaurants.updateOne({_id: ObjectId("59074c7c057aaffaafb0dbb1"), {$set: {name: "Bizz Bar Bang"}}); | |
| Update many documents | |
| db.restaurants.updateMany({address: {zipcode: "10035"}}, {$set: {zipcode: "10036"}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment