Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10907

aggregation usage for $allElementsTrue and $anyElementTrue operators with $project

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • ALL
    • Hide

      > db.people.save(

      {name: 'Gary'}

      )
      > db.people.aggregate({ $match: { } }, { $project: { new:

      { $allElementsTrue: [true] }

      } } )
      Error: Printing Stack Trace
      at printStackTrace (src/mongo/shell/utils.js:37:15)
      at DBCollection.aggregate (src/mongo/shell/collection.js:927:9)
      at (shell):1:11
      2013-09-25T15:19:09.090-0400 aggregate failed: {
      "errmsg" : "exception: $allElementsTrue's argument must be an array, but is Bool",
      "code" : 17040,
      "ok" : 0
      } at src/mongo/shell/collection.js:928

      > db.people.aggregate({ $match: { } }, { $project: { new:

      { $allElementsTrue: [[true]] }

      } } )
      {
      "result" : [

      { "_id" : ObjectId("524323fedcb36f1124a2298e"), "new" : true }

      ],
      "ok" : 1
      }

      Show
      > db.people.save( {name: 'Gary'} ) > db.people.aggregate({ $match: { } }, { $project: { new: { $allElementsTrue: [true] } } } ) Error: Printing Stack Trace at printStackTrace (src/mongo/shell/utils.js:37:15) at DBCollection.aggregate (src/mongo/shell/collection.js:927:9) at (shell):1:11 2013-09-25T15:19:09.090-0400 aggregate failed: { "errmsg" : "exception: $allElementsTrue's argument must be an array, but is Bool", "code" : 17040, "ok" : 0 } at src/mongo/shell/collection.js:928 > db.people.aggregate({ $match: { } }, { $project: { new: { $allElementsTrue: [[true]] } } } ) { "result" : [ { "_id" : ObjectId("524323fedcb36f1124a2298e"), "new" : true } ], "ok" : 1 }

      $anyElementsTrue should take a "simple" array as an argument, but gives a usage error. If the argument is an array with a single element of an array, then it functions but not as expected or desired. The arg should be just the "simple" array - discussed with Matt.

            Assignee:
            Unassigned Unassigned
            Reporter:
            gjmurakami Gary Murakami
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: