destroy method
Deletes records by their primary key(s). Accepts a single ID or a list of IDs. Returns the number of deleted rows.
Example:
await User.query().destroy(1);
await User.query().destroy([1, 2, 3]);
Implementation
Future<int> destroy(dynamic ids) async {
final pkField = definition.primaryKeyField;
if (pkField == null) {
throw StateError('Cannot destroy records without a primary key');
}
final idList = ids is List ? ids : [ids];
if (idList.isEmpty) {
return 0;
}
return await whereIn(pkField.name, idList).delete();
}