delete method
Future<BoolResult>
delete(
- QueryParams params
)
Implementation
Future<BoolResult> delete(QueryParams params) async {
final result = BoolResult(success: false);
if ((params.limit != null && params.limit! > 0) ||
(params.offset != null && params.offset! > 0)) {
result
..success = false
..successMessage =
'You can not use top() or page() function with delete() method';
print(
'SQFENTITY ERROR WHEN DELETE RECORDS: You can not use top() or page() function with delete() method');
return result;
}
if (openedBatch[_dbModel!.databaseName!] == null) {
final Database db = (await this.db)!;
try {
final deletedItems = await db.delete(_tableName!,
where: params.whereString, whereArgs: params.whereArguments);
result
..success = true
..successMessage = '$deletedItems items deleted';
} catch (e) {
result.errorMessage = e.toString();
}
} else {
openedBatch[_dbModel!.databaseName!]!.delete(_tableName!,
where: params.whereString, whereArgs: params.whereArguments);
result
..success = true
..successMessage = 'added to batch that item will be deleted';
}
return result;
}