-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Associations, Query
-
None
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The given code
class User include Mongoid::Document has_many :cgm_evgs end class CgmEvg include Mongoid::Document field :timestamp, type: Date belongs_to :user end User.find(_id: u1.id).cgm_evgs.min(:timestamp).to_a
generates the following command:
{
"aggregate":"cgm_evgs",
"pipeline":[
{"$match":{"user_id":{"$oid":"65a7dfcfe61d72729750604a"},"timestamp":{"$exists":true}}},
{
"$group":{
"_id":"timestamp",
"count":{"$sum":1},
"max":{"$max":"$timestamp"},
"min":{"$min":"$timestamp"},
"sum":{"$sum":"$timestamp"},
"avg":{"$avg":"$timestamp"}
}
}
]
}
The command does not reflect the code.
- has to be done after
-
MONGOID-5526 Create fluid aggregation API
-
- Backlog
-