insert method
Executes a raw INSERT into the database.
WARNING: Bypasses the Model lifecycle (no events, automatic timestamps, or casts). Returns the ID of the inserted record (if supported by the driver, e.g., autoincrement).
Implementation
Future<int> insert(Map<dynamic, dynamic> values) async {
if (values.isEmpty)
throw const InvalidQueryException('Insert values cannot be empty');
final resolvedValues = values.map((key, value) {
final colName = _resolveColumnNameForWrite(key);
_assertIdent(colName, dotted: false, what: 'column name');
return MapEntry(colName, value);
});
return await DatabaseManager().insert(table, resolvedValues);
}