0% found this document useful (0 votes)
430 views

MongoDB Class Assignment

The document provides instructions for 15 MongoDB queries to retrieve information from a restaurants collection. The queries include: 1) Displaying all documents 2) Filtering by borough 3) Sorting and limiting results 4) Filtering by score 5) Filtering by latitude and longitude 6) Excluding results by cuisine and borough 7) Sorting results by name 8) Sorting results by cuisine then borough 9) Checking for existence of field 10) Filtering results not in certain boroughs

Uploaded by

sudeep ghimire
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
430 views

MongoDB Class Assignment

The document provides instructions for 15 MongoDB queries to retrieve information from a restaurants collection. The queries include: 1) Displaying all documents 2) Filtering by borough 3) Sorting and limiting results 4) Filtering by score 5) Filtering by latitude and longitude 6) Excluding results by cuisine and borough 7) Sorting results by name 8) Sorting results by cuisine then borough 9) Checking for existence of field 10) Filtering results not in certain boroughs

Uploaded by

sudeep ghimire
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MongoDB Class assignment

Note:
To import json file please refer steps to import multiple document.doc file.

Write a MongoDB query to display all the documents in the collection


restaurants.

1. Write a MongoDB query to display the fields restaurant_id, name,


borough and cuisine for all the documents in the collection restaurant.

2. Write a MongoDB query to display all the restaurant which is in the


borough Bronx.
3. Write a MongoDB query to display the first 5 restaurant which is in the
borough Bronx.

4. Write a MongoDB query to find the restaurants who achieved a score


more than 90.

5. Write a MongoDB query to find the restaurants that achieved a score,


more than 80 but less than 100.

6. Write a MongoDB query to find the restaurants which locate in latitude


value less than -95.754168.

7. Write a MongoDB query to find the restaurants which do not prepare


any cuisine of 'American' and achieved a score more than 70 and
located in the longitude less than -65.754168.

Note: Do this query without using $and operator.

8. Write a MongoDB query to find the restaurant Id, name, borough and
cuisine for those restaurants which contain 'Wil' as first three letters for
its name.

9. Write a MongoDB query to find the restaurants which do not prepare


any cuisine of 'American ' and achieved a grade point 'A' not belongs to
the borough Brooklyn. The document must be displayed according to
the cuisine in descending order.

10. Write a MongoDB query to find the restaurant Id, name and
grades for those restaurants where the 2nd element of grades array
contains a grade of "A" and score 9 on an ISODate "2019-01-
01T00:00:00.000Z".

11. Write a MongoDB query to find the restaurant Id, name, address
and geographical location for those restaurants where 2nd element of
coord array contains a value which is more than 42 and upto 52.

12. Write a MongoDB query to arrange the name of the restaurants in


ascending order along with all the columns.

13. Write a MongoDB query to arrange the name of the cuisine in


ascending order and for that same cuisine borough should be in
descending order.

14. Write a MongoDB query to know whether all the addresses


contains the street or not.
Note: use $exists

15. Write a MongoDB query to find the restaurant Id, name, borough
and cuisine for those restaurants which are not belonging to the
borough Staten Island or Queens or Bronxor Brooklyn.

You might also like