delete method
Delete this model Delete this model
Implementation
Future<bool> delete([
dynamic id,
]) async {
final currentId = this.id ?? id;
if (currentId == null) return false;
if (DB.driver == DBDriver.mysql) {
// For MySQL, use positional parameters
await DB.execute(
'DELETE FROM ${table.name} WHERE $primaryKey = ?',
positionalParams: [currentId],
);
} else {
// For PostgreSQL, use named parameters
await DB.execute(
'DELETE FROM ${table.name} WHERE $primaryKey = :id',
namedParams: {'id': currentId},
);
}
return true;
}