Intercept and upset create operation? #11815
tago-SE
started this conversation in
Feature Requests & 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.
-
Imagine a built-in collection hook that intercepts create requests and let you decides whether to create a new entry or update an existing one (upset).
This would be especially useful for:
Soft Delete Resurrection: Automatically update (or undelete) an existing record if a new create request matches a soft-deleted entry.
Duplicate Prevention with Remote Data: When importing data from a API you would for example only specify the a remote handle to the object on their service and then populate the other fields based on the remote data. If another user enters the same remote key, rather than creating a new entry you could intercept it and return 200 instead of 201.
Improved Relationship Handling: This approach would streamline the user experience when adding relationships during creation by avoiding redundant entries and reducing boilerplate.
—-
Perhaps there is already a good way to achieve this but I found myself customizing the collection create endpoint which was quite cumbersome.
One simple implementation would be to have an option ‘enableUpsert’ and if the returned data has a Id which already exists it performs the upsert operation. Right now I think it fails.
Beta Was this translation helpful? Give feedback.
All reactions