JavaScript: insert
Perform an INSERT into the table or view.
By default, inserted rows are not returned. To return it, chain the call with .select().
Parameters
values
(Required)The values to insert. Pass an object to insert a single row or an array to insert multiple rows.
options
(Required)Named parameters
Examples
Create a record
const { error } = await supabase
.from('countries')
.insert({ id: 1, name: 'Mordor' })
Handling errors
const { error } = await supabase.from('countries').insert({ id: 1, name: 'Mordor' })
if (error) console.error(error)
Create a record and return it
const { data, error } = await supabase
.from('countries')
.insert({ id: 1, name: 'Mordor' })
.select()
Bulk create
const { error } = await supabase
.from('countries')
.insert([
{ id: 1, name: 'Mordor' },
{ id: 1, name: 'The Shire' },
])
