How use $group like 'group by' in meteor

SellerOrders.aggregate([{$match:{"AttachOrderNo":{$in:OrderNoArr}}},
            {$unwind:'$PurchaseInfos.Addresses'},
            {$group:{_id:'$AttachSellerId',total:{$sum:'$PurchaseInfos.Addresses.Total'}}}]);

client call this method,throw exception

 (node:16962) UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
W20181012-18:10:09.704(8)? (STDERR)     at Array.some (<anonymous>)
W20181012-18:10:09.704(8)? (STDERR)     at Object.matchObject (packages/ejson/ejson.js:180:31)
W20181012-18:10:09.704(8)? (STDERR)     at toJSONValueHelper (packages/ejson/ejson.js:239:19)
W20181012-18:10:09.704(8)? (STDERR)     at Object.EJSON.toJSONValue.item [as toJSONValue] (packages/ejson/ejson.js:292:19)
W20181012-18:10:09.704(8)? (STDERR)     at Object.keys.forEach.key (packages/ejson/ejson.js:188:29)
W20181012-18:10:09.704(8)? (STDERR)     at Array.forEach (<anonymous>)
W20181012-18:10:09.704(8)? (STDERR)     at Object.toJSONValue (packages/ejson/ejson.js:187:24)
W20181012-18:10:09.704(8)? (STDERR)     at toJSONValueHelper (packages/ejson/ejson.js:240:24)
W20181012-18:10:09.704(8)? (STDERR)     at Object.EJSON.toJSONValue.item [as toJSONValue] (packages/ejson/ejson.js:292:19)
W20181012-18:10:09.704(8)? (STDERR)     at Object.keys.forEach.key (packages/ejson/ejson.js:188:29)
W20181012-18:10:09.704(8)? (STDERR)     at Array.forEach (<anonymous>)
W20181012-18:10:09.704(8)? (STDERR)     at Object.toJSONValue (packages/ejson/ejson.js:187:24)
W20181012-18:10:09.704(8)? (STDERR)     at toJSONValueHelper (packages/ejson/ejson.js:240:24)
W20181012-18:10:09.704(8)? (STDERR)     at Object.EJSON.toJSONValue.item [as toJSONValue] (packages/ejson/ejson.js:292:19)
W20181012-18:10:09.704(8)? (STDERR)     at Object.keys.forEach.key (packages/ejson/ejson.js:188:29)
W20181012-18:10:09.704(8)? (STDERR)     at Array.forEach (<anonymous>)
W20181012-18:10:09.705(8)? (STDERR) (node:16962) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
W20181012-18:10:09.705(8)? (STDERR) (node:16962) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

thanks :laughing:

Meteor does not support mongo aggregations. If you want to do that you can use packages like https://github.com/sakulstra/meteor-aggregate (does not support reactive aggregations), or https://github.com/JcBernack/meteor-reactive-aggregate (does support reactive aggregations).

1 Like

thanks :blush::blush::blush::blush::blush: