Project 2
db.collection.createIndex({name:"customer productDetails"})
db.customer productDetails.insertMany([
{_id:1,item:"mobiles",cost:"25000",brand:"1",category:"a", segments:" color:"white",size:"100mm"},
{_id:2,item:"laptops",cost:"45000",brand:"1",category:"b", segments:" color:"grey"},
{_id:3,item:"dresses",cost:"5000",brand:"2",category:"c", segments:" color:"all colors",size:"freesize"},
{_id:4,item:"bags",cost:"2000",brand:"3",category:"d",color:"navy blue"},
]);
db.collection.aggregate({name:'category'})
db.category.insert([
{_id:'678',category:'footwear'},
{_id:'789',category:'cloths'},
{_id:'987',category:'accessories'},
{_id:'423',category:'electronics'},
{_id:'557',category:'jewellery'},
{
$group:
{
"_id":"id",
product:{$name:"$category"}
]);
db.collection.aggregate({name:'sub_category'})
db.sub_category.insertMany([
{_id:'1',items:'electronics'},
{_id:'2',items:'sofas'},
$group:
{
"_id":"id",
product:{$name:"$subcategory"}
]);
db.collection.aggregate({"name":cartDetails})
db.cartDetails.insert([
{_id:'546',product:'add to cart',rename:'delete_Cart',name:'product Added',order:'booked order'}]);
[
{
$group:
{
"_id":"_id",
productname:{$product:'addtocart']};
db.inventory.find({tags:{$product:"c"}});
db.inventory.find({tags:"c"});
db.inventory.find({tags:{$product:"b"}});
db.inventory.find({tags:{$product:"a"}});
db.collection.aggregate({"name":'payment'})
db.payment.insert([
{_id:'987',name:'customer',payment type:'cash on delivery/phonepe/googlepe',order:'booked'}]);
db.collection.createIndex({name:"productDetails"})
db.productDetails.insertMany([
{_id:1,item:"mobiles",cost:"25000",brand:"1",category:"a", segments:" color:"white",size:"100mm"},
{_id:2,item:"laptops",cost:"45000",brand:"1",category:"b", segments:" color:"grey"},
{_id:3,item:"dresses",cost:"5000",brand:"2",category:"c", segments:" color:"all colors",size:"freesize"},
{_id:4,item:"bags",cost:"2000",brand:"3",category:"d",color:"navy blue"},
]);
db.collection.aggregate({name:'category'})
db.category.insert([
{_id:'678',category item 1:'footwear'},
{_id:'789',category item 2:'cloths'},
{_id:'987',category item 3:'accessories'},
{_id:'423',category item 4:'electronics'},
{_id:'557',category item 5:'jewellery'},
{
$group:
{
"_id":"id",
product:{$name:"$category"}
]);
db.collection.aggregate({name:'sub_category'})
db.sub_category.insertMany([
{_id:'1',sub_categoryName:'electronics'},
{_id:'2',sub_categoryName:'sofas'},
$group:
{
"_id":"id",
product:{$name:"$subcategory"}
]);
db.collection.aggregate({"name":cartDetails})
db.cartDetails.insert([
{_id:'546',product:'add to cart',rename:'delete_Cart',name:'product Added',order:'booked order'}]);
[
{
$group:
{
"_id":"_id",
productname:{$product:'addtocart']};
}
}
db.seller.find({tags:{$product:"c"}});
db.seller.find({tags:"c"});
db.seller.find({tags:{$product:"b"}});
db.seller.find({tags:{$product:"a"}});
db.order.aggregate({"receiveOrder"})
db.receiveOrder.insert({
order date:'12-11-2022',
product:'watch',
delivery date:'15-11-2022',
confirm order:'confirm/cancel',
receive order:'received'
});
db.shipment.aggregate([
{
db.shipment.insert({
billing name:'swati nivas',
billing number:'488',
street:'hitech city',
location:'police camp',
place:'hyderabad',
});
$group:{
_id:{shipment:"$shipmentDetails"},
count:{$sum:1}
}
}
{$match:{
count:{"$gt:1}
}
}
]);
db.seller.registered({"sellerDetails"})
db.sellerDetails.insert({
name:"neha",
mobile number:"87654446789",
address:"hitech city",
pin:"5000067",
nation:"india",
});
db:collection.aggregate([
{
db.sellerDetails.insert({
name:"neha",
mobile number:"87654446789",
address:"hitech city",
pin:"5000067",
nation:"india",
});
$group:{
-id:{:"$database"},
count:{$sum:1}
}
}
{$match:{
count:{"$gt":1}
}
}
]);
db.create.database({"submit"})
db.submit.aggregate({
[
submit product:"submitted"]});
1) db.customer.aggregate([{$group:
{
$group:
{
_id:"$item",
avgValue:{$avg:{$multiply:["$price","$quantity"]}},
}
}
])
2) db.greaterthanvalue.find({field1:{$gt:10}});
db.lessthanvalue.find({field1:{$lt:10}});
db.collection.find({field1:{$gt:10,$lt:10});
3) db.collection.find([{
$group:
{
_id:{day:{$dayofYear:"$13"},year:{$year:"$2022"}},
totalAmount:{$sum:{$multiply:["$price","$quantity"]}},
count:{$sum:1}
}
}
]
);
4)db.customers.find([
{
$group:
{$cities:{"$city":hyd},
$count:{"$cityName":hyderabad},
]})
5)db.seller.find({"cityNames"})
db.cityNames.insert({
city:"hyderabad",
db.seller.find([
{"cityname":bengalore},
db.seller.find{"cityname":hyd"},
db.products.find{"name":shreyan}
db.highestnumber.find({$product:"3"}),
db.lowestnumber.find({$product:"2"}),
]);