Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About aggregate queries question #55

Open
dadaxixiyou opened this issue Jul 19, 2019 · 2 comments
Open

About aggregate queries question #55

dadaxixiyou opened this issue Jul 19, 2019 · 2 comments

Comments

@dadaxixiyou
Copy link

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?

@SergejJurecko
Copy link
Owner

Cursor empty like in your example has no effect.

@dadaxixiyou
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants