-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment-3.txt
154 lines (142 loc) · 4.47 KB
/
Assignment-3.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
Assignment - 03
Exercise Questions:-
1. db.getCollection('addressess').find()
2. db.addressess.aggregate([
{$project:{restaurant_id:1,name:1,borough:1,cuisine:1}}
])
3. db.addressess.aggregate([
{$project:{_id:0,restaurant_id:1,name:1,borough:1,cuisine: 1}}
])
4. db.addressess.aggregate([
{$project:{_id:0,restaurant_id:1,name:1,borough:1,zipcode: 1}}
])
5. db.addressess.aggregate([
{$match:{borough:"Bronx"}},
{$limit:5}
])
6. db.addressess.aggregate([
{$match:{borough:"Bronx"}}
])
7. db.addressess.aggregate([
{$match:{borough:"Bronx"}},
{$skip:5},
{$limit:5}
])
8. db.addressess.find({"grades.score":{$gt:90}})
9. db.addressess.find({"grades.score":{$gt : 80 , $lt :100}});
10.db.addressess.aggregate([{$match:{"address.coord":{$lt:-95.75 4168}}}])
11.db.addressess.aggregate([
{$match:{$and:[{cuisine:{$ne:"American "}},
{"grades.score":{$gt:70}},
{"address.coord":{$lt: -65.754168}}
]}}])
12.db.addressess.aggregate([
{$match:{$and:[{cuisine:{$ne:"American "}},
{"grades.score":{$gt:70}},
{"address.coord":{$lt: -65.754168}}
]}}])
13.db.addressess.aggregate([
{$match:{$and:[{cuisine:{$ne:"American "}},
{"grades.grade":{$eq:"A"}},
{borough:{$ne:"Brooklyn"}}]}},
{$sort:{cuisine:-1}}
])
14.db.addressess.find(
{name: /^Wil/},
{
"restaurant_id" : 1,
"name":1,"borough":1,
"cuisine" :1
}
)
15. db.addressess.find(
{name: /ces$/},
{
"restaurant_id" : 1,
"name":1,"borough":1,
"cuisine" :1
}
)
16. db.addressess.find({"name": /.*Reg.*/},{"restaurant_id" : 1,
"name":1,"borough":1,"cuisine" :1})
17. db.addressess.find({ "borough": "Bronx" , $or : [
{ "cuisine" : "American " }{ "cuisine" : "Chinese" }] } )
18. db.addressess.find({"borough" :{$in :["Staten Island","Queens","Bronx","Brooklyn"]}},{"restaurant_id" : 1,
"name":1,"borough":1,"cuisine" :1})
19. db.addressess.find(
{"borough" :{$nin :["Staten Island","Queens","Bronx","Brooklyn"]}},
{
"restaurant_id" : 1,
"name":1,"borough":1,
"cuisine" :1
}
)
20. db.addressess.find({"grades.score" : { $not: {$gt : 10}}},{
"restaurant_id" : 1,"name":1,"borough":1,"cuisine" :1})
21. db.addressess.find(
{$or: [{name: /^Wil/}, {"$and": [
{"cuisine" : {$ne :"American "}},
{"cuisine" : {$ne :"Chinees"}}
]}]},{"restaurant_id" : 1,"name":1,"borough":1,"cuisine" :1})
22. db.addressess.find(
{
"grades.date": ISODate("2014-08-11T00:00:00Z"),
"grades.grade":"A" ,
"grades.score" : 11
},
{"restaurant_id" : 1,"name":1,"grades":1}
);
23.db.addressess.find({"grades.1.date":ISODate("2014-08-11T00:00:00Z"),"grades.1.grade":"A","grades.1.score":9 },{"restaurant_id" :1,"name":1,"grades":1} );
24. db.addressess.find(
{
"address.coord.1": {$gt : 42, $lte : 52}
},
{"restaurant_id" : 1,"name":1,"address":1,"coord":1}
);
25. db.addressess.find().sort(
{"name":1}
);
26. db.addressess.find().sort(
{"name":-1}
);
27. db.addressess.find().sort(
{"cuisine":1,"borough" : -1,}
);
28. db.addressess.find(
{"address.street" :
{ $exists : true }
}
);
29.db.addressess.find(
{"address.coord" :
{$type : 1}
}
);
30. db.addressess.find(
{"grades.score" :
{$mod : [7,0]}
},
{"restaurant_id" : 1,"name":1,"grades":1}
);
31. db.addressess.find(
{ name :
{ $regex : "mon.*", $options: "i" }
},
{
"name":1,
"borough":1,
"address.coord":1,
"cuisine" :1
}
);
32. db.addressess.find(
{ name :
{ $regex : /^Mad/i, }
},
{
"name":1,
"borough":1,
"address.coord":1,
"cuisine" :1
}
);