Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-16604

$documents stage can't be used on a collection-level aggregation

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • manual, Server

    Description

      The mongo server returns an error if we try to use the $documents stage as first stage of an aggregation run on a collection.

       

      Enterprise test> db.test.aggregate([ { $documents: [{ nb: [1, 2, 3] }] }, { $project: { total: { $sum: ["$nb"] } } }] )
      MongoServerError: '$documents' can only be run with {aggregate: 1}

      I suggest updating the Behavior section of the $documents page to say so. Especially since the error message from the server is not very clear for someone that ignore the meaning of {{

      {aggregate: 1}

      }}

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              1 week, 5 days ago