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

aggregate #41

Open
apalexo opened this issue May 3, 2015 · 4 comments
Open

aggregate #41

apalexo opened this issue May 3, 2015 · 4 comments

Comments

@apalexo
Copy link

apalexo commented May 3, 2015

Hi.
Please tell me how to make function" aggregate"
Tnx.

@SergejJurecko
Copy link
Owner

erlmongo supports group call. Check mongoapi.erl
I see mongo docs have an aggregate function. I have not really kept up with mongo api. If this is just a convenience function compared to group call or not I don't know.

@apalexo
Copy link
Author

apalexo commented May 3, 2015

Thanks for your reply.
I need to use aggregate (http://docs.mongodb.org/manual/tutorial/aggregation-with-user-preference-data) - in mongodb aggregate make result more shortest than group and group not work in sharded db.

@apalexo
Copy link
Author

apalexo commented May 3, 2015

For example, I try this:
mongodb:exec_cmd(def,"testdb">>, [{aggregate, [{<<"ns">>, <<"testcol">>},{ <<"$match">>, [{<<"type">>,<<"t">>}]}, {<<"$group">>,[{<<"_id">>,<<"null">>},{<<"sum">>,[{<<"$sum">>,<<"$val">>}]}]}]}])
But result - <<"exception: wrong type for field (aggregate) 3 != 2">>

@SergejJurecko
Copy link
Owner

Can't help you much. Maybe you can check with mongo console. If you run "db.collection.aggregate" you get back the code for this function. This was a reference for a lot of things in this driver.

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