Order Collection
[
{
id: 1,
OrderStatus: "Shipped",
"PurchaseDate" : "2018-01-29T20:59:55Z",
},
{
id: 2,
OrderStatus: "Shipped",
"PurchaseDate" : "2018-01-30T20:59:55Z",
},
{
id: 3,
OrderStatus: "Shipped",
"PurchaseDate" : "2018-01-30T20:59:55Z",
}
];
Order Detail Collection
[
{
orderid: 1,
"QuantityShipped" : "1",
"Amount" : "10",
},
{
orderid: 2,
"QuantityShipped" : "2",
"Amount" : "20",
},
{
orderid: 3,
"QuantityShipped" : "1",
"Amount" : "30",
},
{
orderid: 3,
"QuantityShipped" : "1",
"Amount" : "30",
}
];
Result:
{
sales: 80,
count: 3
}
This is result will get when based on purchase date 2018-01-30T20:59:55Z.
First we need to subtract 7 hours from purchase date then do filter. lets say
if i subtract 7 hours 2018-01-30T20:59:55Z than may or may be not date will change. then we have to
filter based on date.
Sales will calculate based on sum of order detail collection. Count will calculated based on orderdetail count.
how to write query in mongo db.
stringordateand what format. Is it something like this:$match:{PurchaseDate: filterDate}