insert<T> method
Future<T>
insert<T>({
- required List<
SupaInsert< records,B> > - required SupaModifier<
B, R, T, PostgrestBuilder, PostgrestBuilder> modifier, - Set<
SupaColumnBase< ? columns,B> >
Inserts records into the Supabase table.
records
: The list of records to insert.
columns
: The set of columns to fetch. If null, all columns are
fetched.
modifier
: The modifier to apply to the query.
Implementation
Future<T> insert<T>({
required List<SupaInsert<B>> records,
required SupaModifier<B, R, T, PostgrestBuilder<dynamic, dynamic, dynamic>,
PostgrestBuilder<dynamic, dynamic, dynamic>>
modifier,
Set<SupaColumnBase<B>>? columns,
}) async {
final request = supabaseClient
.schema(schema)
.from(tableName)
.insert(records.map((r) => r.toJSON()).toList());
if (modifier is! SupaNoneModifier<B, R>) {
final response = await request
.select(_generateColumnsPattern(columns))
.supaApplyModifier(modifier);
return _castResponse(modifier, response);
}
return (await request) as T;
}