mongoDBhw
mongoDBhw
how restaurants not serving Chinese cuisine and received a grade point 'B', sorted by
cuisine in descending order:
1
Show restaurant_id, name, cuisine, and borough for the first 5 restaurants without _id
field:
Show the next 5 restaurants in the Bronx after skipping the first 5:
2
Show restaurants in Manhattan serving American or Chinese dishes:
3
Show restaurant id, name, borough, and cuisine for restaurants in Staten Island, Queens,
Bronx, or Brooklyn:
Show restaurant id, name, borough, and cuisine for restaurants not in Staten Island,
Queens, Bronx, or Brooklyn:
4
{ "restaurant_id": 1, "name": 1, "borough": 1, "cuisine": 1 }).limit(5)
Part B: Create your own database and collection in MongoDB (using MongoDB
Compass or mongosh). Use proper name for database and collection.
5
Represent the contents in Figure (b) in JSON format
6
Using MongoDB Compass, import the JSON file into your collection or you can
7
manually insert documents using insertMany() (slide 43)
8
Show the contents of your collection (using find())
9
10
11
12
use projection:This query retrieves only the officeCode, city, and country fields from
each document in the OFFICES collection, omitting other fields.
use comparison operator:This query retrieves all documents from the OFFICES
collection where the country field is "USA."
13
14