Skip to content

Latest commit

 

History

History
160 lines (127 loc) · 4.79 KB

File metadata and controls

160 lines (127 loc) · 4.79 KB

MongoDB Queries Practice

Write a MongoDB query to:

  1. Display all the documents in the restaurants collection.
Paste your solution here
  1. Display the fields restaurant_id, name, borough and cuisine for all the documents in the collection.
Paste your solution here
  1. Display the fields restaurant_id, name, borough and cuisine, but exclude the field _id for all the documents in the collection.
Paste your solution here
  1. Display the fields restaurant_id, name, borough and zip code, but exclude the field _id for all the documents in the collection.
Paste your solution here
  1. Display all the restaurants which are in the borough Bronx.
Paste your solution here
  1. Display the first 5 restaurants which are in the borough Bronx.
Paste your solution here
  1. Display the next 5 restaurants after skipping first 5 which are in the borough Bronx.
Paste your solution here
  1. Find the restaurants who achieved a score more than 90.
Paste your solution here
  1. Find the restaurants that achieved a score, more than 80 but less than 100.
Paste your solution here
  1. Find the restaurants which are located in latitude value less than -95.754168.
Paste your solution here
  1. Find the restaurants that do not prepare any cuisine of 'American' and their grade score is more than 70 and latitude less than -65.754168.
Paste your solution here
  1. Find the restaurants which do not prepare any cuisine of 'American' and achieved a score more than 70 and are located in the longitude less than -65.754168.

Note : Do this query without using $and operator.

Paste your solution here
  1. Find the restaurants which do not prepare any cuisine of 'American' and achieved a grade point 'A' and does not belong to the borough Brooklyn. The document must be displayed according to the cuisine in descending order.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which contain 'Wil' as first three letters in its name.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which contain 'ces' as last three letters in its name.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which contain 'Reg' as three letters somewhere in its name.
Paste your solution here
  1. Find the restaurants which belong to the borough Bronx and prepare either American or Chinese cuisine.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which belong to the boroughs Staten Island or Queens or Bronx or Brooklyn.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which don't belong to the boroughs Staten Island or Queens or Bronx or Brooklyn.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which achieved a score that is not more than 10.
Paste your solution here
  1. Find the restaurant_id, name, borough and cuisine for those restaurants which either prepare dishes except 'American' and 'Chinese' or has a name which begins with the letters 'Wil'.
Paste your solution here
  1. Find the restaurant_id, name, and grades for those restaurants which achieved an A grade and scored 11 on the date "2014-08-11T00:00:00Z" among many of survey dates.
Paste your solution here
  1. 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 "2014-08-11T00:00:00Z".
Paste your solution here
  1. 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.
Paste your solution here
  1. Arrange the name of the restaurants in ascending order along with all the columns.
Paste your solution here
  1. Arrange the name of the restaurants in descending along with all the columns.
Paste your solution here
  1. Arrange the restaurants in ascending order of cuisines and descending order of boroughs.
Paste your solution here
  1. Check whether all the resturant addresses contain the street or not.
Paste your solution here
  1. Display all documents in the restaurants collection where the coord field value is a Double.
Paste your solution here
  1. Display the restaurant_id, name and grades for those restaurants which have a grade divisible by 7.
Paste your solution here
  1. Find the restaurant name, borough, longitude and latitude and cuisine for those restaurants which contain 'mon' as three letters somewhere in its name.
Paste your solution here