-
Notifications
You must be signed in to change notification settings - Fork 27
Add useUpsert hook #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/zoo/react-supabase/ERQZxHW3ztxWvAgnaAxrhGzS8QiX |
tmm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. One small thing, then I'll merge and release.
| ## Notes | ||
|
|
||
| - By specifying the `onConflict` option, you can make `UPSERT` work on a column(s) that has a `UNIQUE` constraint. | ||
| - Primary keys should to be included in the data payload in order for an update to work correctly. | ||
| - Primary keys must be natural, not surrogate. There are however, workarounds for surrogate primary keys. | ||
| - Param `filter` makes sense only when operation is update | ||
| - Upsert supports sending array of elements, just like `useInsert` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these
Co-authored-by: Tom Meagher <tom@meagher.co>

Motivation
Created a hook that will use the functionality exposed by
supabase-jsfor doing insert or update queries viaupsert()method.Related
Docs
/docs/pages/documentation/data/use-upsert.md