-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise5.txt
224 lines (216 loc) · 5.77 KB
/
exercise5.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
- Display the fields restaurant_id, name, borough and cuisine for all the documents in the collection restaurant
restaurants> db.restaurants.find({},{restaurant_id:1 , name:1, borough:1, cuisine:1})
[
{
_id: ObjectId("63d2fc716ffccfbefa49827b"),
borough: 'Bronx',
cuisine: 'Bakery',
name: 'Morris Park Bake Shop',
restaurant_id: '30075445'
},
{
_id: ObjectId("63d2fc716ffccfbefa49827c"),
borough: 'Brooklyn',
cuisine: 'Hamburgers',
name: "Wendy'S",
restaurant_id: '30112340'
},
{
_id: ObjectId("63d2fc716ffccfbefa49827d"),
borough: 'Manhattan',
cuisine: 'Irish',
name: 'Dj Reynolds Pub And Restaurant',
restaurant_id: '30191841'
},
{
_id: ObjectId("63d2fc716ffccfbefa49827e"),
borough: 'Brooklyn',
cuisine: 'American',
name: 'Riviera Caterer',
restaurant_id: '40356018'
},
{
_id: ObjectId("63d2fc716ffccfbefa49827f"),
borough: 'Queens',
cuisine: 'Jewish/Kosher',
name: 'Tov Kosher Kitchen',
restaurant_id: '40356068'
},
{
_id: ObjectId("63d2fc716ffccfbefa498280"),
borough: 'Queens',
cuisine: 'American',
name: 'Brunos On The Boulevard',
restaurant_id: '40356151'
},
{
_id: ObjectId("63d2fc716ffccfbefa498281"),
borough: 'Staten Island',
cuisine: 'Jewish/Kosher',
name: 'Kosher Island',
restaurant_id: '40356442'
},
{
_id: ObjectId("63d2fc716ffccfbefa498282"),
borough: 'Brooklyn',
cuisine: 'Delicatessen',
name: "Wilken'S Fine Food",
restaurant_id: '40356483'
},
{
_id: ObjectId("63d2fc716ffccfbefa498283"),
borough: 'Brooklyn',
cuisine: 'American',
name: 'Regina Caterers',
restaurant_id: '40356649'
},
{
_id: ObjectId("63d2fc716ffccfbefa498284"),
borough: 'Brooklyn',
cuisine: 'Ice Cream, Gelato, Yogurt, Ices',
name: 'Taste The Tropics Ice Cream',
restaurant_id: '40356731'
},
{
_id: ObjectId("63d2fc716ffccfbefa498285"),
borough: 'Bronx',
cuisine: 'American',
name: 'Wild Asia',
restaurant_id: '40357217'
},
{
_id: ObjectId("63d2fc716ffccfbefa498286"),
borough: 'Brooklyn',
cuisine: 'American',
name: 'C & C Catering Service',
restaurant_id: '40357437'
},
{
_id: ObjectId("63d2fc716ffccfbefa498287"),
borough: 'Brooklyn',
cuisine: 'Chinese',
name: 'May May Kitchen',
restaurant_id: '40358429'
},
{
_id: ObjectId("63d2fc716ffccfbefa498288"),
borough: 'Manhattan',
cuisine: 'American',
name: '1 East 66Th Street Kitchen',
restaurant_id: '40359480'
},
{
_id: ObjectId("63d2fc716ffccfbefa498289"),
borough: 'Brooklyn',
cuisine: 'Jewish/Kosher',
name: 'Seuda Foods',
restaurant_id: '40360045'
},
{
_id: ObjectId("63d2fc716ffccfbefa49828a"),
borough: 'Brooklyn',
cuisine: 'Ice Cream, Gelato, Yogurt, Ices',
name: 'Carvel Ice Cream',
restaurant_id: '40360076'
},
{
_id: ObjectId("63d2fc716ffccfbefa49828b"),
borough: 'Queens',
cuisine: 'Ice Cream, Gelato, Yogurt, Ices',
name: 'Carvel Ice Cream',
restaurant_id: '40361322'
},
{
_id: ObjectId("63d2fc716ffccfbefa49828c"),
borough: 'Brooklyn',
cuisine: 'Delicatessen',
name: 'Nordic Delicacies',
restaurant_id: '40361390'
},
{
_id: ObjectId("63d2fc716ffccfbefa49828d"),
borough: 'Manhattan',
cuisine: 'American',
name: 'Glorious Food',
restaurant_id: '40361521'
},
{
_id: ObjectId("63d2fc716ffccfbefa49828e"),
borough: 'Brooklyn',
cuisine: 'American',
name: 'The Movable Feast',
restaurant_id: '40361606'
}
]
- Display the second group of 5 restaurants which are in the borough Bronx
restaurants> db.restaurants.find({borough:"Bronx"},{name:1, borough:1}).skip(5).limit(5)
[
{
_id: ObjectId("63d2fc716ffccfbefa4982b8"),
borough: 'Bronx',
name: 'Manhem Club'
},
{
_id: ObjectId("63d2fc716ffccfbefa4982d0"),
borough: 'Bronx',
name: 'The New Starling Athletic Club Of The Bronx'
},
{
_id: ObjectId("63d2fc716ffccfbefa4982e4"),
borough: 'Bronx',
name: 'Yankee Tavern'
},
{
_id: ObjectId("63d2fc716ffccfbefa4982fa"),
borough: 'Bronx',
name: 'Mcdwyers Pub'
},
{
_id: ObjectId("63d2fc716ffccfbefa49830e"),
borough: 'Bronx',
name: 'The Punch Bowl'
}
]
- Find the restaurants who achieved a score more than 90
restaurants> db.restaurants.find({"grades.score":{$gt:90}},{name:1,score:1})
[
{
_id: ObjectId("63d2fc716ffccfbefa4983d3"),
name: "Murals On 54/Randolphs'S"
},
{ _id: ObjectId("63d2fc716ffccfbefa498473"), name: 'Gandhi' },
{ _id: ObjectId("63d2fc716ffccfbefa4985d9"), name: 'Bella Napoli' }
- Find the restaurants that do not prepare any cuisine of 'American' and their grade score more than 70 and latitude less than -65.754168.
restaurants> db.restaurants.find({cuisine:{$ne:'American'},"grades.score":{$gt:70},"address.coord.0":{$lt:-65.754168}},{name:1, cuisine:1, "address.coord":1})
[
{
_id: ObjectId("63d2fc716ffccfbefa498473"),
address: { coord: [ -73.9864626, 40.7266739 ] },
cuisine: 'Indian',
name: 'Gandhi'
},
{
_id: ObjectId("63d2fc716ffccfbefa4985d9"),
address: { coord: [ -73.984758, 40.7457939 ] },
cuisine: 'Pizza/Italian',
name: 'Bella Napoli'
},
{
_id: ObjectId("63d2fc716ffccfbefa4985f2"),
address: { coord: [ -73.9243061, 40.8276297 ] },
cuisine: 'Latin (Cuban, Dominican, Puerto Rican, South & Central American',
name: 'El Molino Rojo Restaurant'
},
{
_id: ObjectId("63d2fc716ffccfbefa498735"),
address: { coord: [ -73.94610279999999, 40.7137587 ] },
cuisine: 'Bakery',
name: 'Fortunato Bros Cafe & Bakery'
},
{
_id: ObjectId("63d2fc716ffccfbefa498d61"),
address: { coord: [ -73.9772294, 40.7527262 ] },
cuisine: 'Italian',
name: 'Two Boots Grand Central'
}
]