Javascript Reference v1.0

Upsert data

  • Primary keys should 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.
  • If you need to insert new data and update existing data at the same time, use Postgres triggers.

const { data, error } = await supabase
  .upsert({ id: 3, message: 'foo', username: 'supabot' })