{"warehouseNsId":"15","brandId":37,"financeOwnerId":1231882808817905665,"currencyUnit":"CNY","amount":0,"items":[{"goodsNsId":"1353","price":"256.00","count":1},{"goodsNsId":"1799","price":"254.80","count":1},{"goodsNsId":"1353","price":"256.00","count":1}]}
資料如上,有若干條,如何按items.goodsNsId 分組?得出如下期望的資料:
{"warehouseNsId":"15","brandId":37,"financeOwnerId":1231882808817905665,"currencyUnit":"CNY","amount":0,"items":[{"goodsNsId":"1353","price":"512.00","count":2},{"goodsNsId":"1799","price":"254.80","count":1}]}
uj5u.com熱心網友回復:
{
"warehouseNsId":"15","brandId":37,"financeOwnerId":1231882808817905665,"currencyUnit":"CNY","amount":0,
"items":[
{"goodsNsId":"1353","price":"256.00","count":1},
{"goodsNsId":"1799","price":"254.80","count":1},
{"goodsNsId":"1353","price":"256.00","count":1}
]
}
期望如下,如何寫相關的查詢陳述句?
{
"warehouseNsId":"15","brandId":37,"financeOwnerId":1231882808817905665,"currencyUnit":"CNY","amount":0,
"items":[
{"goodsNsId":"1353","price":"512.00","count":2},
{"goodsNsId":"1799","price":"254.80","count":1}
]
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/19863.html
標籤:MongoDB
