erlmongo icon indicating copy to clipboard operation
erlmongo copied to clipboard

About aggregate queries question

Open dadaxixiyou opened this issue 5 years ago • 2 comments

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?

dadaxixiyou avatar Jul 19 '19 10:07 dadaxixiyou

Cursor empty like in your example has no effect.

SergejJurecko avatar Jul 19 '19 10:07 SergejJurecko

I'm still not sure how to use the cursor properly,can you give me example?

dadaxixiyou avatar Jul 20 '19 06:07 dadaxixiyou