- 
    Type:
Task
 - 
    Resolution: Done
 - 
    Affects Version/s: None
 - 
    Component/s: None
 
- 
        None
 
- 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 - 
        None
 
I have a MongoDB shell command which works fine. The command is:
db.sessions.aggregate({$unwind: "$Sessions List"}, {$match: { "Sessions List.Parent Session Name":"Reader Session"}}, {$group:{_id:"$Sessions List.Parent Session Name", avg_val:{$avg:"$Sessions List.Length"}}})
result is: "result" : [
{ "_id" : "Reader Session", "avg_val" : 8.846666666666666 }],
"ok" : 1
but when trying to run it through Mongoid (using latest available Mongoid, Origin, Moped) it falls with NoMethodError (undefined method `bson_load' for nil:NilClass) exception.
Ruby code is the following:
Session.collection.aggregate({
        '$unwind' => '$Sessions List',
        '$match' => 
,
        '$group' => {
            '_id' => '$Sessions List.Parent Session Name',
            'avg_val' => 
}});