Complete MongoDB HW
This commit is contained in:
93
Mongo/mongo-notes.js
Normal file
93
Mongo/mongo-notes.js
Normal file
@@ -0,0 +1,93 @@
|
||||
/* Nicholas Tamassia */
|
||||
|
||||
db.order_lines.find()
|
||||
{ "_id": ObjectId('692130567e8e9828c389b03d'), "product_order": 1511, "product": 212, "quantity": 2 }
|
||||
|
||||
|
||||
// Find all orders for product 212
|
||||
db.order_lines.find({ product: 212 });
|
||||
{ _id: ObjectId('692130567e8e9828c389b03d'), product_order: 1511, product: 212, quantity: 2 }
|
||||
{ _id: ObjectId('692130567e8e9828c389b055'), product_order: 1538, product: 212, quantity: 15 }
|
||||
{ _id: ObjectId('692130567e8e9828c389b059'), product_order: 1577, product: 212, quantity: 6 }
|
||||
|
||||
// Find all products with less than 20 available quantity
|
||||
db.products.find({ available_quantity: { $lt: 20 } })
|
||||
{ _id: 185, name: 'Chateau Petrus, 1975', type: 'red', available_quantity: 5 }
|
||||
{ _id: 219, name: 'Marques de Caceres, Rioja Crianza, 2010 ', type: 'red', available_quantity: 0 }
|
||||
{ _id: 265, name: 'Chateau Sociando-Mallet, Haut-Medoc, 1998', type: 'red', available_quantity: 17 }
|
||||
{ _id: 331, name: 'Chateau La Commanderie, Lalande-de-Pomerol, 1998', type: 'red', available_quantity: 3 }
|
||||
{ _id: 494, name: 'Veuve-Cliquot, Brut, 2012', type: 'sparkling', available_quantity: 1 }
|
||||
{ _id: 523, name: 'Chateau Andron Blanquet, Saint Estephe, 1979', type: 'red', available_quantity: 13 }
|
||||
{ _id: 783, name: "Clos D'Opleeuw, Chardonnay, 2012", type: 'white', available_quantity: 8 }
|
||||
|
||||
// Find all suppliers in New York
|
||||
{ _id: 21, name: 'Deliwines', address: '240, Avenue of the Americas', city: 'New York', status: 20 }
|
||||
|
||||
// What rose and white wines have more than 50 quantity available?
|
||||
db.products.find({ type: { $in: [ 'rose', 'white' ] }, available_quantity: { $gt: 50 } })
|
||||
{ _id: 119, name: 'Chateau Miraval, Cotes de Provence Rose, 2015', type: 'rose', available_quantity: 126 }
|
||||
{ _id: 289, name: 'Chateau Saint Estève de Neri, 2015', type: 'rose', available_quantity: 126 }
|
||||
{ _id: 300, name: 'Chateau des Rontets, Chardonnay, Birbettes', type: 'white', available_quantity: 64 }
|
||||
{ _id: 632, name: 'Meneghetti, Chardonnay, 2010', type: 'white', available_quantity: 83 }
|
||||
{ _id: 668, name: 'Gallo Family Vineyards, Grenache, 2014', type: 'rose', available_quantity: 95 }
|
||||
{ _id: 899, name: 'Trimbach, Riesling, 1989', type: 'white', available_quantity: 142 }
|
||||
|
||||
// Find all restaurants in London. Show only the id, name, and rating. Order by rating descending
|
||||
db.restaurants.find({ location: "London" }, { name: 1, rating: 1 }).sort({ rating: -1 })
|
||||
{ _id: 55, name: 'Alasia', rating: 'Not yet rated' }
|
||||
{ _id: 101, name: 'Anokha Indian Bar & Restaurant', rating: 'Not yet rated' }
|
||||
{ _id: 15, name: 'Aarthi', rating: 6 }
|
||||
{ _id: 165, name: 'Bamboo Box', rating: 5.5 }
|
||||
{ _id: 174, name: 'Barbican Tandoori', rating: 5.5 }
|
||||
{ _id: 23, name: 'Absolute Caribbean', rating: 5 }
|
||||
{ _id: 24, name: 'Absolute Caribbean', rating: 5 }
|
||||
{ _id: 31, name: 'Admiral Pizza', rating: 5 }
|
||||
{ _id: 40, name: 'AK Chicken Food', rating: 5 }
|
||||
{ _id: 59, name: 'Alfa Pizza & Chicken', rating: 5 }
|
||||
{ _id: 67, name: 'All Nations Dalston', rating: 5 }
|
||||
{ _id: 137, name: 'Azeri Cuisine', rating: 5 }
|
||||
{ _id: 138, name: 'Azka Turkish Meze', rating: 5 }
|
||||
{ _id: 166, name: 'Bamboo Garden', rating: 5 }
|
||||
{ _id: 186, name: 'Bedouin Lounge Grill & Mezza Bar', rating: 5 }
|
||||
{ _id: 199, name: 'Bengal Berties', rating: 5 }
|
||||
{ _id: 200, name: 'Bengal Brasserie', rating: 5 }
|
||||
{ _id: 202, name: 'Bengal Lancer', rating: 5 }
|
||||
{ _id: 1, name: '@ Thai Restaurant', rating: 4.5 }
|
||||
{ _id: 35, name: 'Ai Sushi', rating: 4.5 }
|
||||
|
||||
// Find people who have given a rating of 5 to any restaurant. Show only the name and restaurant ID. Order by name ascending
|
||||
db.restaurants.find({ rating: 5 }, { name: 1 }).sort({ name: 1 })
|
||||
{ _id: 3, name: '23rd Street Pizza' }
|
||||
{ _id: 4, name: '23rd Street Pizza' }
|
||||
{ _id: 5, name: '333 Chinese Takeaway' }
|
||||
{ _id: 6, name: '4 Seasons Pizza & Grill' }
|
||||
{ _id: 7, name: '5 Star Pizza' }
|
||||
{ _id: 8, name: '5 Star Pizza' }
|
||||
{ _id: 9, name: '62 Worksop Fish Bar' }
|
||||
{ _id: 11, name: '9 Inch CFC' }
|
||||
{ _id: 40, name: 'AK Chicken Food' }
|
||||
{ _id: 41, name: 'AK Grill' }
|
||||
{ _id: 16, name: "Aayan's" }
|
||||
{ _id: 19, name: 'Abdul Spice' }
|
||||
{ _id: 21, name: 'Abidap Connection' }
|
||||
{ _id: 22, name: 'Abo Ali - Lebanese Cuisine' }
|
||||
{ _id: 23, name: 'Absolute Caribbean' }
|
||||
{ _id: 24, name: 'Absolute Caribbean' }
|
||||
{ _id: 27, name: "Adam's Pizzeria" }
|
||||
{ _id: 26, name: 'Adams Pizza Corner' }
|
||||
{ _id: 28, name: 'Adana Pizza' }
|
||||
{ _id: 29, name: 'Adeel Balti & Pizza Bar' }
|
||||
|
||||
// Find all restaurants containing "Thai" in the type of food. Hint: Use { $regex: "Thai", $options: "i" }. Return the name and address of the restaurant
|
||||
db.restaurants.find({ type_of_food: { $regex: "Thai", $options: "i" } }, { name: 1, address: 1, _id: 0 })
|
||||
{ address: '30 Greyhound Road Hammersmith', name: '@ Thai Restaurant' }
|
||||
{ address: '235-241 High Street', name: "Anna's Thai Restaurant" }
|
||||
{ address: '235-241 High Street', name: "Anna's Thai Restaurant" }
|
||||
{ address: '21 Market Road', name: 'Asian Box' }
|
||||
{ address: '18 Fortess Road', name: 'Baan Thai' }
|
||||
{ address: 'Unit 23 55-59 Weir Road', name: 'Bamboo Baboom' }
|
||||
{ address: 'Unit 23 55-59 Weir Road', name: 'Bamboo Baboom' }
|
||||
{ address: '194 Shoreditch High Street', name: 'Bamboo Box' }
|
||||
{ address: '1 Ecclesall Road', name: 'Ban Thai' }
|
||||
{ address: '55 Southgate Elland', name: 'Bang Thai Dee' }
|
||||
{ address: '21 Rose Street', name: 'Bhan Thai' }
|
||||
Reference in New Issue
Block a user