をモンゴするために、私は、クエリをモンゴするには、以下のSQLを変換したい:変換のSQLクエリは、クエリ
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;
が、私はグループでそれを使用しなくても、プロジェクト内のstock_updated_at
を見つけたいです。
これは、既存のコンバータを使用して試すことができます私のmongoquery
db.x.aggregate([
{
"$group": {
"_id": { "Brand": "$Brand"},
"TotalStock": { "$sum": 1 },
"OutOfStock": { "$sum": ....
....
....