Create data: insert()
Performs an INSERT into the table.
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554}
]).execute();
Notes
- By default, every time you run
insert()
, the client library will make aselect
to return the full record. This is convenient, but it can also cause problems if your Policies are not configured to allow theselect
operation. If you are using Row Level Security and you are encountering problems, try setting thereturning
param tominimal
.
Examples
Create a record
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554}
]).execute();
Bulk create
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554},
{'name': 'Rohan', 'country_id': 555},
]).execute();