group by in ruby mongoid

Solutions on MaxInterview for group by in ruby mongoid by the best coders in the world

showing results for - "group by in ruby mongoid"
Hannah
20 Sep 2018
1Lead.where(client_id: client.id.to_s).collection.aggregate([{"$group"=>{ :_id=> "$sales_id" , :count=>{"$sum"=>1} } }, {"$match": { count: { "$gte": 3 } }} ]).to_a
2