save method
Save the model (insert if new, update if exists)
Implementation
Future<void> save() async {
final companion = toCompanion();
if (primaryKey == null || primaryKey == 0) {
// Insert new record
await database.into(table).insert(companion);
} else {
// Update existing record
await (database.update(table)
..where((tbl) => _primaryKeyEquals(tbl, primaryKey)))
.write(companion);
}
}