insert method
Insere values em table e retorna o id gerado.
Implementation
@override
Future<int> insert(String table, Map<String, Object?> values) async {
final r = await _client.post(
Uri.parse('$_base/$table'),
headers: {..._headers, 'prefer': 'return=representation'},
body: jsonEncode(values),
);
if (r.statusCode >= 400) {
throw Exception('Supabase insert ${r.statusCode}: ${r.body}');
}
final rows = jsonDecode(r.body) as List;
return ((rows.first as Map)['id'] as num?)?.toInt() ?? 0;
}