upsert
Insert a row or update the row that conflicts with its key.
Use this when Importing or saving a setting may encounter an existing record.
without the term
“When importing, if the record already exists I want to update it, otherwise create it. Right now it checks first and sometimes creates duplicates when two imports run at once.”
with the term · How do you ask a model for upsert?
Use an upsert for these settings with the correct unique key. Verify new and existing rows without a separate existence check.
What is upsert?
An upsert combines insert-or-update behavior under a database conflict rule. It still needs a deliberate update policy.
Why does upsert matter when vibe coding?
A separate existence check can race with another writer.
How do you do upsert?
Choose the conflict key and allowed updates. Check new rows, existing rows, and simultaneous submissions.
What goes wrong with upsert?
A stale request overwrites newer data; upsert alone does not resolve version conflicts.