Challenge

Project 2

a. db.customer.insert( {customerID: 45,firstname:"kiran",lastname:"bodkhe",addresses:[{street:" at antapur"}]);

b. db.customer.insert({normal member:"30",premium member:"20"})

c.db.carts.insert({ _id: "product_id", status:'active', quantity: 20, total: 5000, products: []});

d.db.products.insertMany([{"categories":6,"brands":"Addidas,","segments":5}]);

e.db.category.insertOne([{"subcategories":8}]);

f. db.aggregateproducts.insertMany([{tags:['categories','subcategories'],like:40}]);

g. db.createcollection "(cart")

db.carts.insert({ _id: "product_id", status:'active', login: 6, logout: 4, products: []});

db.tracking:( { tracking_number: "88766ffg77", status: "on",estimated_delivery: new ISODate("2012-05-17T08:14:15.656Z") },

h. db.createcollection("admin")

db.admin.inserts({"sellerid":56})

db.product.insertMany([{'categories'],like:100}]);

i. db.createcollection("seller")

db.orders.insert({ created_on: new Date("2023-05-01")});

j.db.createcollection("order")

tracking:( { tracking_number: "88766ffg77", status: "pending"});

payment: { method: "visa", transaction_id: "54555jjjh455" }

k. db.seller.insertOne({"phone_no":8605642068,"name":"nikheel bodkhe","address":" sambaji nage auragpura, 431103"});

1.Write a query to find the average order value for all Customers.

db.coustomer.find().aggregate(field_name).sort()

2.Query your database to get top 10 customers whose orders have the highest value and who have been customers since less than 2 months

db.customer.find({months:{$lt:10}};

db.checkdate.find( { status: "delivery",estimated_delivery: new ISODate("2012-05-17T08:14:15.656Z") });

3.Query your database to find the sum of all orders received in this month

db.orders.find({$groupby:[{$max:"orders"},{"customer_date"<40}]});

4.Query your database to find customers count in various cities, group them by names of cities

db.aggregatecustomers.insertMany([{titles:'cities',description:'names',by:'count',tags:['cities','names','count'],likes:299}]);

5.Query your database to get all the sellers who have base in the same city in which the customers who ordered their products. Order them in the order of highest number of products sold to customers in same city to lowest.

db.customers.aggregate([{$group:[_id:{products:"$products"},count:{$sum:1}}},{$match:{count:{"$lt":1}}}]);

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.