[SERVER-35896] Support "replaceDocuments" mode in $out Created: 28/Jun/18 Updated: 29/Oct/23 Resolved: 06/Aug/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.2 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Kyle Suarez | Assignee: | Nicholas Zolnierz |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | Query 2018-07-16, Query 2018-07-30, Query 2018-08-13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
If an existing document already exists with the same unique key, the old document is replaced with the new one. |
| Comments |
| Comment by Githook User [ 02/Aug/18 ] |
|
Author: {'username': 'nzolnierzmdb', 'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com'}Message: |
| Comment by Kyle Suarez [ 10/Jul/18 ] |
|
I filed |
| Comment by Nicholas Zolnierz [ 10/Jul/18 ] |
|
Makes sense to me, though I'd prefer to keep the uniqueKey work separate from this ticket. Also kyle.suarez, one other subtlety that we discussed in addition to what you mentioned above is allowing a missing _id in the pipeline document since the update will autogenerate one. |
| Comment by Kyle Suarez [ 10/Jul/18 ] |
Yeah, we definitely want to keep that with dropTarget: true. When dropTarget: false, I think it's sufficient to check once at aggregation planning time, and not before every call to spill(). |
| Comment by Charlie Swanson [ 10/Jul/18 ] |
|
Oh, yea this totally makes sense. I forgot in the scope, we are allowed to require the 'uniqueKey' be provably unique via a unique index. We might be able to do the same trick that we do for existing $out, where before we finish up we assert that the same indices and options still exist, thereby checking that it's still unique. |
| Comment by Kyle Suarez [ 10/Jul/18 ] |
|
Per in-person discussion, we think a reasonable approach is:
I think it would be useful to push forward with this to have something working and see if the semantics are what we want. I'll also schedule time to discuss this more broadly with the team/product. |
| Comment by Kyle Suarez [ 28/Jun/18 ] |
|
Let's use the update system to do this; ideally with upsert: "true". |