Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2829

exception when using aggregation framework (undefined method `__bson_load__' for nil:NilClass)

      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' =>

      { 'Sessions List.Parent Session Name' => 'Reader Session'}

      ,
      '$group' => {
      '_id' => '$Sessions List.Parent Session Name',
      'avg_val' =>

      { '$avg' => '$Sessions List.Length' }

      }});

            Assignee:
            Unassigned Unassigned
            Reporter:
            ivankarpey ivankarpey
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: