[SERVER-33482] update existing item or push a new item to an array in a document Created: 26/Feb/18 Updated: 08/Jun/21 Resolved: 26/Feb/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Dinesh Chander | Assignee: | Ramon Fernandez Marina |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
I want to update an object or push an object to an array in one query? For e.g if the document is
I want to add a new object
to list if this object doesn't exists in the list otherwise I want to update it.
Since condition in arrayFilter will return false, $pushIfNoMatch operator will work and the new state of document will be
if we change the condition to $eq: 1, the $set operator will work and new state will be
|
| Comments |
| Comment by Ewan Higgs [ 07/Jun/21 ] |
|
I think this is a valuable feature and much simpler than the alternatives proposed in Basically, arrays support insert ($push), update (using arrayFilters), and this ticket is about making upsert operations on arrays. Can this be reopened? Or would I need to make a new ticket?
Thanks |
| Comment by Ramon Fernandez Marina [ 26/Feb/18 ] |
|
dispareil, I think the functionality you're requesting is a subset of Thanks, |