[DOCS-13489] Make behavior for literal empty object in $project/$addFields clearer Created: 03/Mar/20  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Ian Boros Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: docs-query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769

 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.)



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Comment by Asya Kamsky [ 16/Jun/20 ]

$const is internal - externally we document $literal (its alias I believe)

Generated at Thu Feb 08 08:07:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.