aggregation framework - How do i express this sql statement in mongodb -



aggregation framework - How do i express this sql statement in mongodb -

i tried poking around see basic examples.

i looking express following:

select average((a+b)/c) table

i have:

db.props.aggregate( [ { $group: { _id: "$id", a_: { $avg: "$a" },b_:{$avg:"$b"} } }, {$match:{a_:{$gt:0},b_:{$gt:0}}} ] )

but missing pieces. tried applying operations in $avg statement doesnt work.

something this?

{ $group: { _id: "$_id", average: { $avg: { $divide: [ {$add: ["$a","$b"]}, "$c" ] } } } }

mongodb aggregation-framework

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -