Last active
June 5, 2017 20:55
-
-
Save wilm42/e2c58ced64fcffba7aac9909cc97d83f 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
//MORNING ASSIGNMENTS | |
1. db.restaurants.find() | |
2. db.restaurants.find().sort({name: 1}).limit(10) | |
3. var documentId = ObjectId('5934b07a13358bfc0a5434b4'); db.restaurants.findOne({_id: documentId}); | |
4. db.restaurants.find({borough: "Queens"}).pretty() | |
5. db.restaurants.count() | |
6. db.restaurants.find({"address.zipcode": "11206"}).pretty() | |
7. db.restaurants.remove({_id: ObjectId("593578055412460076a9a12c")}) | |
8. db.restaurants.update( { _id: ObjectId("593578055412460076a9a12d") }, { $set:{ name: "Bizz Bar Bang" } } ) | |
9. db.restaurants.update( { "address.zipcode" : "10035"}, { $set:{ "address.zipcode": "10036" } }, { multi: true } ) | |
//AFTERNOON ASSIGNMENTS | |
db.restaurants.find( | |
{ | |
cuisine: {$ne: "Not Listed/Not Applicable"}, | |
borough: {$ne: "Missing"}, | |
grades: { $exists:true, $ne: "Not Yet Graded", $elemMatch:{score:{$ne:-1}} } | |
}).pretty() | |
How many were filtered out?: (I know y'all wanted that) 808 (can you feel that B-A-S-S bass) | |
List of unique cuisines that match our criteria: | |
db.restaurants.distinct( | |
"cuisine", | |
{ | |
cuisine: {$ne: "Not Listed/Not Applicable"}, | |
borough: {$ne: "Missing"}, | |
grades: { $exists:true, $ne: "Not Yet Graded", $elemMatch:{score:{$ne:-1}} } | |
} | |
) | |
First five restaurants with the lowest positive score in one of their gradings: | |
db.restaurants.find( | |
{ | |
cuisine: {$ne: "Not Listed/Not Applicable"}, | |
borough: {$ne: "Missing"}, | |
grades: { $exists:true, $ne: "Not Yet Graded", $elemMatch:{score:{$gt:-1}} } | |
}).sort({'grades.score': -1}).limit(5).pretty() | |
the restaurants which have only been graded A | |
db.restaurants.find( | |
{ | |
cuisine: {$ne: "Not Listed/Not Applicable"}, | |
borough: {$ne: "Missing"}, | |
grades: { $exists:true, $ne: "Not Yet Graded", $elemMatch:{grade: "A"} } | |
}).pretty() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment