If id is the primary key or an unique index you could do:
db
.insert(cities)
.values(data)
.onDuplicateKeyUpdate(
{
set: { name: sql`VALUES(name)` }
}
)
db
.insert(cities)
.values(data)
.onDuplicateKeyUpdate(
{
set: { name: sql`VALUES(name)` }
}
)
It feels like that should be faster, but you'll have to do your own tests
Also, you should check the length of the array, I believe arrays over certain length will throw errors