-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.txt
230 lines (218 loc) · 6.11 KB
/
product.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
224
225
226
227
228
229
230
// Product Deta is given Below
// 1.Find all the information about each products
db.products.find()
// 2.Find the product price which are between 400 to 800
db.products.find({product_price:{$gte:400,$lte:800}})
// 3.Find the product price which are not between 400 to 600
db.products.find({$or:[{product_price:{$gt:600}},{product_price:{$lt:400}}]})
// 4.List the four product which are grater than 500 in price
db.products.find({product_price:{$gt:500}}).limit(4)
// 5.Find the product name and product material of each products
db.products.find().forEach((pro) => {
print("Product Name: " + pro.product_name);
print("Product Material: " + pro.product_material);
})
// 6.Find the product with a row id of 10
db.products.find({id:"10"})
// 7.Find only the product name and product material
db.products.find().forEach((pro) => {
print("Product Name: " + pro.product_name);
print("Product Material: " + pro.product_material);
})
// 8.Find all products which contain the value of soft in product material
db.products.find({product_material:'Soft'})
// 9.Find products which contain product color indigo and product price 492.00
db.products.find({product_color:'indigo',product_price:492.00})
// 10.Delete the products which product price value are same
db.products.aggregate([
{
$group:{
_id:"$product_price",
duplicate:{$addToSet:"$_id"},
TotalCount:{$sum:1},
}
},
{
$match:{TotalCount:{$gt:1}}
}
]).forEach((doc) => {
doc.duplicate.shift()
db.products.deleteMany({ _id: {$in:doc.duplicate}})
})
db.products.insertMany([
{
"id": "1",
"product_name": "Intelligent Fresh Chips",
"product_price": 655.00,
"product_material": "Concrete",
"product_color": "mint green"
},
{
"id": "2",
"product_name": "Practical Fresh Sausages",
"product_price": 911.0,
"product_material": "Cotton",
"product_color": "indigo"
},
{
"id": "3",
"product_name": "Refined Steel Car",
"product_price": 690.00,
"product_material": "Rubber",
"product_color": "gold"
},
{
"id": "4",
"product_name": "Gorgeous Plastic Pants",
"product_price": 492.00,
"product_material": "Soft",
"product_color": "plum"
},
{
"id": "5",
"product_name": "Sleek Cotton Chair",
"product_price": 33.00,
"product_material": "Fresh",
"product_color": "black"
},
{
"id": "6",
"product_name": "Awesome Wooden Towels",
"product_price": 474.00,
"product_material": "Plastic",
"product_color": "orange"
},
{
"id": "7",
"product_name": "Practical Soft Shoes",
"product_price": 500.00,
"product_material": "Rubber",
"product_color": "pink"
},
{
"id": "8",
"product_name": "Incredible Steel Hat",
"product_price": 78.00,
"product_material": "Rubber",
"product_color": "violet"
},
{
"id": "9",
"product_name": "Awesome Wooden Ball",
"product_price": 28.00,
"product_material": "Soft",
"product_color": "azure"
},
{
"id": "10",
"product_name": "Generic Wooden Pizza",
"product_price": 84.00,
"product_material": "Frozen",
"product_color": "indigo"
},
{
"id": "11",
"product_name": "Unbranded Wooden Cheese",
"product_price":26.00,
"product_material": "Soft",
"product_color": "black"
},
{
"id": "12",
"product_name": "Unbranded Plastic Salad",
"product_price": 89.00,
"product_material": "Wooden",
"product_color": "pink"
},
{
"id": "13",
"product_name": "Gorgeous Cotton Keyboard",
"product_price": 37.00,
"product_material": "Concrete",
"product_color": "sky blue"
},
{
"id": "14",
"product_name": "Incredible Steel Shirt",
"product_price": 54.00,
"product_material": "Metal",
"product_color": "white"
},
{
"id": "15",
"product_name": "Ergonomic Cotton Hat",
"product_price": 43.00,
"product_material": "Rubber",
"product_color": "mint green"
},
{
"id": "16",
"product_name": "Small Soft Chair",
"product_price": 47.00,
"product_material": "Cotton",
"product_color": "teal"
},
{
"id": "17",
"product_name": "Incredible Metal Car",
"product_price":36.00,
"product_material": "Fresh",
"product_color": "indigo"
},
{
"id": "18",
"product_name": "Licensed Plastic Bacon",
"product_price":88.00,
"product_material": "Steel",
"product_color": "yellow"
},
{
"id": "19",
"product_name": "Intelligent Cotton Chips",
"product_price": 46.00,
"product_material": "Soft",
"product_color": "azure"
},
{
"id": "20",
"product_name": "Handcrafted Wooden Bacon",
"product_price": 36.00,
"product_material": "Concrete",
"product_color": "lime"
},
{
"id": "21",
"product_name": "Unbranded Granite Chicken",
"product_price": 90.00,
"product_material": "Metal",
"product_color": "gold"
},
{
"id": "22",
"product_name": "Ergonomic Soft Hat",
"product_price": 99.00,
"product_material": "Rubber",
"product_color": "black"
},
{
"id": "23",
"product_name": "Intelligent Steel Pizza",
"product_price": 95.00,
"product_material": "Cotton",
"product_color": "azure"
},
{
"id": "24",
"product_name": "Tasty Rubber Cheese",
"product_price":47.00,
"product_material": "Frozen",
"product_color": "orchid"
},
{
"id": "25",
"product_name": "Licensed Steel Car",
"product_price":20.00,
"product_material": "Cotton",
"product_color": "indigo"
}
]);