JavaScript: update | Supabase Docs

JavaScript: update

Perform an UPDATE on the table or view.

By default, updated rows are not returned. To return it, chain the call with .select() after filters.

Parameters

  • values

    (Required)

    The values to update with

  • options

    (Required)

    Named parameters

Examples

Updating your data

const { error } = await supabase
  .from('instruments')
  .update({ name: 'piano' })
  .eq('id', 1)

Handling errors

const { error } = await supabase.from('instruments').update({ name: 'piano' }).eq('id', 1)
if (error) console.error(error)

Update a record and return it

const { data, error } = await supabase
  .from('instruments')
  .update({ name: 'piano' })
  .eq('id', 1)
  .select()

Updating JSON data

const { data, error } = await supabase
  .from('users')
  .update({
    address: {
      street: 'Melrose Place',
      postcode: 90210
    }
  })
  .eq('address->postcode', 90210)
  .select()