Project 2
1.a.db.createcollection(“customer”);
db.customer.insermany({[“_id”:1,”name”:”sunil”,”address”:”srikalahasthi”, “gender”:”m”},
{“_id”:2,”name”:”sun”,”address”:”pune“,”gender”:”m”},
{“_id”:3,”name”:”surya”,”address”:”sirisilla”,”gender”:”m”},
{“_id”:4,”name”:”siri”,”address”:”kalyan”,”gender”:”f”}
});
b.db.customer.add({[“customer_type”:”normal”,”customer_type”:”premium”}]);
c.db.invent.find({tags:”products”});
db.customer.add({[“product_name”:”cart”}]);
d.db.invent.insertmany([
{_id:1,item:{name:”dress”,”category”:”tops”},brand:”only”,segments:[“shops”,”e-store”]},
{_id:2,item:{name:”grocery”,”category”:”toor dhal”},brand:”reliace”,segments:[“shops”,”markets”]}
]);
e.db.createcollection(“category”,”subcategories”);
f.db.getcollection(‘orders’).aggregate([{
$lookup:
{
from:’products’,
localfield:’product_id’,
foreignfield:’_id’,
as:’orderdetails’
}
}]);
g.db.createcollection(“payment”);
h.db.createcollection(“admin”);
db.createcollection(“seller”);
db.seller.add([{“products”:”categories”,tags:”a”,”b”}]);
i.db.invent.find({tags:”orders”});
j.db.createcollection(“shipping”);
db.shipping.insertmany([{“_id”:1,”type”:”cash on delivery”,”order”:”dress”},
{“_id”:2,”type”:”credit card”,”card no.”:12345,”order”:”grocery”}
]);
k.db.seller.insertmany([{“_id”:5,”name”:”akash”,”gender”:”m”,”address”:”chennai”},
{“_id”:6,”name”:”salman”,”gender”:”m”,”address”:”banglore”}
]);
1.db.createcollection(1.”customer”,
2.”category”,
3.”admin”,
4.”payment”,
5.”seller”,
6.”shipping”);
Querys:
1.db.aggregatecustomer.aggregate({$avg:”order value”});
2.db.bios.find().limit(10)
db.bios.find().sort({customer:order_id}).limit(10)
db.bios.find().limit(10).sort({customer:order_id});
db.aggregatecustomer.aggregate({$lt:2});
3.db.aggregateorder.aggregate({$sum:”order_value”});
4.db.aggregatecustomer.aggregate([{$group:{_id:”$by_city”,num_tutorial:{$count:”customer_city”}}}]);
5.db.aggregatecustomer.aggregate([{$group:{_id:”$seller_city”,_id:”$product”,num_tutorial:{$sort:
“products_city”}}}]);