Challenge

Project 2

1.

use ecom;

//

db.user.insertMany([{user_type:"admin"},{user_type:"seller"},{user_type:"customer"}]);

//

db.customer.insertMany([{c_name:"rohan saha",c_mobileNo:"+91 7003224592",c_email:"[email protected]",c_country:"india",c_city:"pune",c_address:"sector 2, pune",user_type:"customer",password:"qwqwq123",gender:"m",payment_info:"",created_at:new Date(Date.now())},{c_name:"dip roy",c_mobileNo:"+91 7003124592",c_email:"[email protected]",c_country:"india",c_city:"kolkata",c_address:"salt lake, sector 1, kolkata",user_type:"customer",password:"asasasd23",gender:"m",payment_info:"",created_at:new Date(Date.now())},{c_name:"juhi agarwal",c_mobileNo:"+91 9003224592",c_email:"[email protected]",c_country:"india",c_city:"bangalore",c_address:"ramnagar, bangalore",user_type:"customer",password:"21qw34",gender:"f",payment_info:"",created_at:new Date(Date.now())}])

//

db.seller.insertMany([{s_name:"cristine",s_mobile:"+91 8013344653",s_email:"[email protected]",s_password:"12wweasdw1",s_country:"india",s_city:"kolkata",s_address:"kolkata, west bengal",category:"electronics",created_at:new Date(Date.now()),product_sold:18},{s_name:"caroline",s_mobile:"+91 8013354653",s_email:"[email protected]",s_password:"gfhrt4562",s_country:"india",s_city:"delhi",s_address:"delhi",category:"clothes",created_at:new Date(Date.now()),product_sold:3},{s_name:"suhas",s_mobile:"+91 8012344653",s_email:"[email protected]",s_password:"dfrrew4456",s_country:"india",s_city:"pune",s_address:"pune, maharastra",category:"furniture",created_at:new Date(Date.now()),product_sold:13}])

//

db.category.insertMany([{_id:1,category_name:"electronics",category_desc:"all type of electronics",trending:"",discount:""},{_id:2,category_name:"clothes",category_desc:"all type of clothes",trending:"",discount:""},{_id:3,category_name:"home appliances",category_desc:"all type of home appliances",trending:"",discount:""},{_id:4,category_name:"groceries",category_desc:"all type of groceries",trending:"",discount:""},{_id:5,category_name:"office appliances",category_desc:"all type of office appliances",trending:"",discount:""}])

//

db.sub_category.insertMany([{_id:1,category_id:2,sub_category_name:"men clothes",sub_category_desc:"all type of men clothes",trending:"",discount:""},{_id:2,category_id:1,sub_category_name:"laptops",sub_category_desc:"all type of laptops",trending:"",discount:""},{_id:3,category_id:1,sub_category_name:"mobiles",sub_category_desc:"all type of mobiles",trending:"",discount:""},{_id:4,category_id:2,sub_category_name:"women clothes",sub_category_desc:"all type of women clothes",trending:"",discount:""},{_id:5,category_id:5,sub_category_name:"office desk",sub_category_desc:"all type of office desks",trending:"",discount:""},{_id:6,category_id:3,sub_category_name:"almirah",sub_category_desc:"all type of almirah",trending:"",discount:""}])

//

db.products.insertMany([{_id:1,sub_category_id:2,brand:"dell",color:"silver",name:"dell alienware 15",size:"15 inch",weight:"3.2 kg",price:"1,80,000 inr",desc:"dell alienware 15 comes with latest intel i9 1200p 12th gen cpu,16 gb ggr5 ram,rtx 3090 ti 8gb ddr6 vram and ultra cooling technology which offers you seamless gaming and multitasking experience",ratings:4,image:""}])

db.products.insertMany([{_id:2,sub_category_id:1,brand:"prada",color:"black",name:"prada lether jacket",size:"M",price:"18,000 inr",desc:"lether jacket for men",ratings:4,image:""}])

db.products.insertMany([{_id:3,sub_category_id:4,brand:"pantaloons",color:"red",name:"pantaloons kurti for women",size:"M",price:"900 inr",desc:"kurti for women",ratings:4.5,image:""}])

//

db.cart.insertMany([{_id:1,customer_id:"63863eb1e86a2bd367a457ae",product_id:2,cart_desc:"",image:"",created_at:new Date(Date.now())}])

//

db.orders.insertMany([{_id:1,customer_id:"63863eb1e86a2bd367a457ad",product_id:1,payment_method:"DEBIT card",payment_id:"34ert6q",ammount:"1,80,000 inr",delivery_address:"qwwqwqw",seller_id:2,customer_mobile:"+91 7003124592",customer_email:"[email protected]",is_confirmed:1,created_at:new Date(Date.now())}])

//

1.db.orders.aggregate([{$group:{_id:"$customer_id",ammount:{$avg:"$ammount"}}}])

2.db.orders.aggregate([{$sort:{ammount:-1}},{$limit:10}])

3.db.orders.aggregate([{$group:{_id:{ month: { $month: "$created_at"}, year: { $year: "$created_at" } },ammount:{$sum:"$ammount"}}}])

4.db.customer.aggregate([{ "$group": { _id: "$c_city", count: { $sum: 1 } } }])

5.db.seller.aggregate([{ "$group": { _id: "$s_city", max: { $max: "$product_sold" } } }])

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.