erlmongo
erlmongo copied to clipboard
About aggregate queries question
mongoapi:runCmd([ {"aggregate", ?ORDER_TABLE}, {"cursor", #{ } }, {"pipeline", {array,[ [ {"$match", #{status=>0}} ], [ {"$group",[ {"_id","null"}, {"total", [{"$sum", "$amount"}]} ]} ] ]} } ], ?MONGO_MASTER),
the query result is: [{<<"cursor">>, [{<<"firstBatch">>, {array,[[{<<"_id">>,<<"null">>},{<<"total">>,1900}]]}}, {<<"id">>,0}, {<<"ns">>,<<"paycenter_db.pay_order">>}]}, {<<"ok">>,1.0}]
Can you give me a correct demonstration? Cursor is a mandatory parameter, but I am not sure how to use it. Do I need to close cursor?
Cursor empty like in your example has no effect.
I'm still not sure how to use the cursor properly,can you give me example?