- Open mongo shell
- Create a new database called “meal”
- Create a collection called ‘saloon’ for database ‘meal’.
- Import
saloon.json
file to “saloon” collection.
mongoimport --db <DATABASE_NAME> --collection <COLLECTION_NAME> --file <FILE_NAME>
- Print all the documents in the collection saloon.
- Print the fields restaurant_id, name, area and cooking for all the documents in the collection saloon.
- Print the fields restaurant_id, name, area and cooking, but exclude the field _id for all the documents in the collection saloon.
- Print the fields restaurant_id, name, area and zip code, but exclude the field _id for all the documents in the collection saloon.
- Print all the restaurant which is in the area Bronx.
- Print the first 5 restaurant which is in the area Bronx.
- Print the next 5 restaurants after skipping first 5 which are in the area Bronx.
- Find the restaurants who achieved a score more than 90.
- Find the restaurants that achieved a score, more than 80 but less than 100.
- Find the restaurants which locate in latitude value less than -95.754168.
- Find the restaurants that do not prepare any cooking of 'American' and their grade score more than 70 and latitude less than -65.754168.
- Find the restaurants which do not prepare any cooking 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.
- Find the restaurants which do not prepare any cooking of 'American ' and achieved a grade point 'A' not belongs to the area Brooklyn. The document must be displayed according to the cooking in descending order.
- Find the restaurant Id, name, area and cooking for those restaurants which contain 'Wil' as first three letters for its name.
- Find the restaurant Id, name, area and cooking for those restaurants which contain 'ces' as last three letters for its name.
- Find the restaurant Id, name, area and cooking for those restaurants which contain 'Reg' as three letters somewhere in its name.