delete method
Implementation
@override
Future<int> delete({
final Filter Function(TMeta t)? where,
final bool? useIsolate,
final bool? all,
}) async {
assert(all == true || where != null,
'Either provide where query or specify all = true to delete all.');
final db = await dbContext.database;
final formattedQuery = where != null
? await whereString(
where,
useIsolate,
)
: null;
return await db.transaction<int>((txn) async {
var batch = txn.batch();
batch.delete(
t.tableName,
where: formattedQuery?.filter,
whereArgs: formattedQuery?.whereArgs,
);
var result = await batch.commit(noResult: false, continueOnError: false);
if (result.isEmpty) {
return 0;
}
final res = result[0];
if (res is int) {
return res;
}
return 0;
});
}