update method
The update
method updates an existing entity.
Implementation
@override
FutureOr<void> update(
HouseholdModel entity, {
bool createOpLog = true,
}) async {
return retryLocalCallOperation(() async {
final householdCompanion = entity.companion;
final addressCompanion = entity.address
?.copyWith(
relatedClientReferenceId: entity.clientReferenceId,
auditDetails: entity.auditDetails,
clientAuditDetails: entity.clientAuditDetails,
)
.companion;
await sql.batch((batch) async {
batch.update(
sql.household,
householdCompanion,
where: (table) => table.clientReferenceId.equals(
entity.clientReferenceId,
),
);
if (addressCompanion != null) {
batch.update(
sql.address,
addressCompanion,
where: (table) => table.relatedClientReferenceId.equals(
addressCompanion.relatedClientReferenceId.value!,
),
);
}
});
await super.update(entity, createOpLog: createOpLog);
});
}