JavaScript: Insert data

Examples

Create a record

const \{ data, error \} = await supabase
  .from('cities')
  .insert([
    \{ name: 'The Shire', country_id: 554 \}
  ])

Bulk create

const \{ data, error \} = await supabase
  .from('cities')
  .insert([
    \{ name: 'The Shire', country_id: 554 \},
    \{ name: 'Rohan', country_id: 555 \},
  ])

Upsert

const \{ data, error \} = await supabase
  .from('cities')
  .insert(
    [
      \{ name: 'The Shire', country_id: 554 \},
      \{ name: 'Rohan', country_id: 555 \},
      \{ name: 'City by the Bay', country_id:840\}
    ],
    \{ upsert: true \})