[SERVER-84943] POC: Merging style of $out Created: 06/Mar/19  Updated: 12/Jan/24  Resolved: 09/Apr/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Charlie Swanson Assignee: Anton Korshunov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Query 2019-03-25, Query 2019-04-08, Query 2019-04-22
Participants:

 Description   

In PM-1021 we are still flushing out the syntax of how to do so, but we're proposing adding a mode for $out or a $out-like stage which will take documents from the pipeline and merge them with documents in the collection, like {$mergeObjects: [<existing>, <new>]}. Fields present only in the existing document remain unchanged. Fields present only in the computed document are added to the document. Fields present in both documents will take the value from the new document. This applies to top-level fields, sub-objects are not merged.

In this POC, we should add a new flag to $out (I propose just using a new mode "mergeDocuments" for now, since that's at least one of the options on the table) and add the ability for $out to do this. To achieve this, we just need a new subclass of $out which calls a new method on the process interface. This will look very similar to this call, but instead of just directly passing the objects from the batch, it should wrap each one in a {$set: <object>} to make it so the update has the semantics we want.


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