MySql 8 - How to use onDuplicateKeyUpdate with array?

as the title says, how do i use onDuplicateKeyUpdate with arrays? I can pass an array to .values() function but after that i have no idea how to handle duplicate. Help would be appriciated. thanks
3 Replies
Angelelz
Angelelz14mo ago
Can you show what you're trying to write in SQL?
Whooopps
WhoooppsOP14mo ago
I figured it out I think. I just start a transaction and map over the array and if there is duplicate then its easy to update that way
Luxaritas
Luxaritas14mo ago
You probably don’t want to do that, as it means executing a new query per item in your array, which gets more problematic the bigger it gets If you’re looking to get access to a value you passed to the initial insert call, you can reference it like
sql`VALUES(${column})`
sql`VALUES(${column})`
Want results from more Discord servers?
Add your server