delete method
The delete
method deletes an existing entity.
Implementation
@override
FutureOr<void> delete(
HouseholdModel entity, {
bool createOpLog = true,
}) async {
return retryLocalCallOperation(() async {
final updated = entity.copyWith(
isDeleted: true,
clientAuditDetails: (entity.clientAuditDetails?.createdBy != null &&
entity.clientAuditDetails?.createdTime != null)
? ClientAuditDetails(
createdBy: entity.clientAuditDetails!.createdBy,
createdTime: entity.clientAuditDetails!.createdTime,
lastModifiedBy: entity.clientAuditDetails!.lastModifiedBy,
lastModifiedTime: DateTime.now().millisecondsSinceEpoch,
)
: null,
rowVersion: entity.rowVersion,
);
await sql.batch((batch) {
batch.update(
sql.household,
updated.companion,
where: (table) => table.clientReferenceId.equals(
entity.clientReferenceId,
),
);
});
return super.delete(updated);
});
}