erlmongo
erlmongo copied to clipboard
aggregate
Hi. Please tell me how to make function" aggregate" Tnx.
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.
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.
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">>
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.