Create data: insert()
Perform an INSERT into the table or view.
By default, inserted rows are not returned. To return it, chain the call
with .select().
1const { error } = await supabase
2 .from('countries')
3 .insert({ id: 1, name: 'Denmark' })
Parameters#
valuesrequired
|RowarrayThe values to insert. Pass an object to insert a single row or an array to insert multiple rows.
- required
objectobjectNo description provided.
Rowrequired
objectNo description provided.
Properties
optionsrequired
objectNamed parameters
countoptional
|exact|plannedestimatedCount algorithm to use to count inserted rows.
"exact": Exact but slow count algorithm. Performs aCOUNT(*)under the hood."planned": Approximated but fast count algorithm. Uses the Postgres statistics under the hood."estimated": Uses exact count for low numbers and planned count for high numbers.
Properties
Examples#
Create a record#
1create table 2 countries (id int8 primary key, name text);
1const { data, error } = await supabase 2 .from('countries') 3 .select()
Create a record and return it#
1create table 2 countries (id int8 primary key, name text);
Bulk create#
A bulk create operation is handled in a single transaction. If any of the inserts fail, none of the rows are inserted.
1create table 2 countries (id int8 primary key, name text);
1const { data, error } = await supabase 2 .from('countries') 3 .select()