Lack of "upsert"-like behaviour. #1535
schalkventer
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Searching the docs it seems that the only way to do upsert-like operations is directly via the utils, and not via the collection methods themselves (similar to
insertandupdate).This generally means the following:
insertorupdatein response.updateyou need to create anObject.assign(currentItem, newItem)inside the immer-like mutation (due to not being able to override root objects in immer).This feels like something that would be a common operation, so was a bit suprised that there is no functionality to handle upserting/replacing when exists - unless there is and I missed it (which means it needs to maybe be made more clear in the docs/API).
Beta Was this translation helpful? Give feedback.
All reactions