below is all the description collection 1 : users
"_id" : ObjectId("5e2977e1cc1208c65c00648b"),
"mappedShops" : [
ObjectId("5e2976cbcc1208c65c006488"),
ObjectId("5e2976cbcc1208c65c00690c"),
ObjectId("5e2976cbcc1208c65c006499")
"phoneNo" : 6789012345,
"name" : "acdbcs",
"address" : "address 2",
"shopCode" : "D3137",
"state" : "M.P",
"city" : "Indore"
NOTE: deatils of mappedShops for e.g: ObjectId("5e2976cbcc1208c65c00690c") is in the same users collection
collection 2 : orders
"_id" : ObjectId("5e27f998a42d441fe8a8957f"),
"isApproved" : false,
"orderCreatedOn" : ISODate("2020-01-22T18:30:00Z"),
"shopOrder" : [],
"frequency" : "WE",
"orderCreatedBy" : ObjectId("5e2976cbcc1208c65c00690c")
Collection 3: payments
"_id" : ObjectId("5dd7900bcd00d33c245abbfa"),
"paymentOfTheDay" : 400,
"outstanding" : 100,
"paymentDoneBy":ObjectId("5e2976cbcc1208c65c00690c")
scenario is : i will get _id(i.e admin id) from req.body Here is what i need to do 1: i need to know all the mappedShops objectId's & than for all those objectId's i need to find the details of all those objectId's 2: than i need to look what order that shop has created from order collection.(for all those id's) 3: than i need to look what is the outstanding from the payments collection(again for all the id's) Here is what i need to send to the frontend in the mentioned object Array {"name","phoneNo","address"}(from users collection)+{"orderCreatedOn": ISODate("2020-01-22T18:30:00Z"),"isApproved"}(from orders collection)+{"outstanding"}(from payments collection) expected response may look like this:
"shopsListDetails":[{
"phoneNo","name","address","shopCode" ,"isApproved","outstanding"
}]
POSTMAN REQUEST this is the id of admin
{
"_id": "5e2977e1cc1208c65c00648b"
}
ultimately front end shall receive all the data which i mentioned in shopsListDetails[{}] for all the mappedShops in the user collection against that admin I am kind of very much stuck in this if any can help me out