Created
August 16, 2017 01:59
-
-
Save michaelablackham/e6ef30bfd3d1f09f210a6c36ca907a2c 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(10); | |
| //Get by _id | |
| db.restaurants. | |
| find({"_id": ObjectId("599399ad535efc3e9694cf4a")}) | |
| //Get by Value | |
| db.restaurants.find({cuisine: "Irish"}); | |
| //Count | |
| db.restaurants.count() | |
| //Count by nester value | |
| db.restaurants.find({'grades.grades': 'A'}).count() | |
| //Delete by ID | |
| db.restaurants.remove({_id: ObjectId("599399ad535efc3e9694cf4a")}); | |
| //Update single document | |
| db.restaurants.updateOne( | |
| {_id: ObjectId("599399ad535efc3e9694cf4a")}, | |
| {$set: {name: 'Bizz Bar Bang'}}); | |
| //Update many documents | |
| db.restaurants.updateMany( | |
| {'borough': 'Manhattan'}, | |
| {$set: {'borough': 'Brooklyn'}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment