Does the .upsert() onConflict support something li...
# help
l
Does the .upsert() onConflict support something like DO NOTHING in stead of updating updated fields??
n
Hello @Lars! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
https://supabase.com/docs/reference/javascript/upsert Probably ignoreDuplicates is what you are looking for
n
Lars (2022-04-22)
l
It doens't worked as I hoped.
it seems to ignore all rows instead of just the duplicate ones
Copy code
| id | raw_id | raw_data        |
| -- | ------ | --------------- |
| 3  | 1      | [object Object] |
| 4  | 2      | [object Object] |
| 6  | 3      | [object Object] |
If I upsert ```js [{"raw_id": 1, "raw_data":"test"}, {"raw_id": 4, "raw_data":"test2"}] ```js
none of them are inserted
Expected outcome was that the following would have been inserted ```js {"raw_id": 4, "raw_data":"test2"} ```js
raw_id is unique
g
Seems like that is what is for, but I've not used it. Do you have your onConflict column set?
l
No, I was thinking only one of the two could be used
g
try that to, it may trigger the mode
OK I'm going to guess maybe it means if there is more than one row that matches don't do anything at this point. I don't find any documentation other than that line.
l
like this: ```js .upsert(newQuery, { onConflict: 'raw_id' }, { ignoreDuplicates: true }) ```js
g
All options go in one {}
l
OMG that works. I feel stupid! But thank you guys SO much!