[DOCS-12818] Highlight that _id should be removed before using $merge without _id in 'on' fields Created: 21/Jun/19 Updated: 30/Oct/23 Resolved: 05/Jul/19 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual, Server |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Kay Kim (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 4 years, 31 weeks, 5 days ago |
| Epic Link: | DOCS: 4.2 Server/Tools |
| Description |
DescriptionWhen designing the $merge stage we realized that using a set of 'on' fields other than _id will often result in the user accidentally trying to modify the _id of the target document. When the 'whenMatched' mode is "merge" (the default), the update generated by the $merge stage will include the _id from the document in the pipeline which is likely different than the one targeted by the 'on' fields. Further, because $project includes the _id by default, it might not be obvious to users whether the document going into $merge has an _id at all. cc asya Scope of changesImpact to Other DocsMVP (Work and Date)Resources (Scope or Design Docs, Invision, etc.) |
| Comments |
| Comment by Githook User [ 05/Jul/19 ] |
|
Author: {'name': 'Kay Kim', 'username': 'kay-kim', 'email': 'kay.kim@10gen.com'}Message: |
| Comment by Kay Kim (Inactive) [ 21/Jun/19 ] |
|
We currently state
Will add the aforementioned workaround of removing the _id field. as well as include the workaround in https://docs.mongodb.com/master/reference/operator/aggregation/merge/#existing-documents-and-id-and-shard-key-values section |