Ich möchte die folgende SQL-Abfrage konvertieren Mongo:Convert SQL-Abfrage Mongo Abfrage
SELECT brand_name,
count(`inventory`) AS totalstock,
count(if(`inventory`=0, `inventory`, NULL)) as outofstock,
count(if(`inventory`!=0, `inventory`, NULL)) as availablestock,
DATE_ADD(stock_updated_at, INTERVAL 318 minute) as stock_updated_at
FROM x group by Brand order by stock_updated_at desc;
I stock_updated_at
in Projekt finden möchten, ohne sie auf die Gruppe mit.
Das ist mein mongoquery
db.x.aggregate([
{
"$group": {
"_id": { "Brand": "$Brand"},
"TotalStock": { "$sum": 1 },
"OutOfStock": { "$sum": ....
....
....