diff --git a/employees-lab.js b/employees-lab.js new file mode 100644 index 0000000..88e1ecd --- /dev/null +++ b/employees-lab.js @@ -0,0 +1,22 @@ +// List all the employees. +on mongoDB compass open db, open collection, click FIND +// Find the employee with whose name is Steve. +{ name: "Steve" } => FIND +// Find all employees whose age is greater than 30. +{ age: { $gt: 30 } } => FIND +// Find the employee whose extension is 2143. +{ "phone.ext": "2143" } => FIND +// Find all employees that are over 30. +{ age: { $gt: 30 } } => FIND +// Find all employees that are less than or equal to 30. +{ age: { $lte: 30 } } => FIND +// Find all the employees whose favorite food is pizza. +{ "favorites.food": "pizza" } => FIND +// Change Willy’s personal phone number to "93-123-45-67". +findOneAndUpdate( { name: "Wylly" }, { "phone.personal": "93-123-45-67" }) +// Change Bob’s privilege to normal user. +findOneAndUpdate( { name: "Bob" }, { privileges: "user" }) +// Find all employees whose favorite artist is equal to Picasso. +{"favorites.artist": "Picasso"} => FIND +// Delete the user John. +findOneAndDelete( { name: "John" } ) \ No newline at end of file diff --git a/restaurans-lab.js b/restaurans-lab.js new file mode 100644 index 0000000..92a9392 --- /dev/null +++ b/restaurans-lab.js @@ -0,0 +1,21 @@ +// List all the restaurants. +on mongoDB compass open db, open collection, click FIND +// Find all the restaurants and display only the fields restaurant_id, name, borough and cuisine. + +// Find all the restaurants and display only the fields restaurant_id, name, borough and zip code. +// Find the restaurants which are in the borough Bronx. +{ borough: "Bronx" } => FIND +// Find the restaurants which are in the borough Brooklyn with Steak cuisine. +{ borough: "Brooklyn", cuisine: "Steak" } => FIND +// Find the restaurants which have achieved a score bigger than 90. +{ "grades.score": { $gt: 90 } } => FIND +// Find the restaurants that do not prepare any Bakery cuisine and with a grade score equal or bigger than 70. +{ cuisine: { $ne: "Bakery" }, "grades.score": { $gte: 70 } } => FIND +// Find the restaurants which do not prepare any Chinese cuisine and have achieved a grade point A which do not belong to the borough Manhattan. +{ cuisine: { $ne: "Chinese" }, "grades.grade": { $eq: "A" }, borough: { $ne: "Manhattan}" } } => FIND +// Update restaurants with 'American ' cuisine to 'American' (without the space!!!) +updateMany( { cuisine: "American " }, { cuisine: "American" }) +// Update Morris Park Bake Shop address street to Calle falsa 123. +findOneAndUpdate( {"addres.street": "Morris Park Ave", cuisine: "Bakery" }, { "addres.street": "Calle falsa 123" } ) +// Delete all the restaurants with address zipcode 10466. +deleteMany( { "addres.zipcode": "10466" } ) \ No newline at end of file