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

Make behavior for literal empty object in $project/$addFields clearer

    XMLWordPrintableJSON

Details

    Description

      Description

      In SERVER-46422 a user was confused about why the following $project/$addFields is invalid:

      db.c.aggregate({$project: {a: {}}}) 

      db.c.aggregate({$addFields: {a: {}}}) 

       

      We should consider updating the docs to indicate that in these cases $literal needs to be used:

      db.c.aggregate({$project: {a: {$literal: {}}}}) 

      (and similar for $addFields)

       

      Maybe this page could have a sentence or two about this:

      https://docs.mongodb.com/manual/reference/operator/aggregation/project/

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Activity

          People

            Unassigned Unassigned
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago