update method

  1. @override
FutureOr<void> update(
  1. HFReferralModel entity, {
  2. bool createOpLog = true,
})
override

The update method updates an existing entity.

Implementation

@override
FutureOr<void> update(
  HFReferralModel entity, {
  bool createOpLog = true,
}) async {
  return retryLocalCallOperation(() async {
    final referralCompanion = entity.companion.copyWith(
      name: Value(entity.additionalFields?.fields
          .where(
            (h) =>
                h.key ==
                ReferralReconAdditionalFields.nameOfReferral.toValue(),
          )
          .first
          .value),
    );

    await sql.batch((batch) {
      batch.update(
        sql.hFReferral,
        referralCompanion,
        where: (table) => table.clientReferenceId.equals(
          entity.clientReferenceId,
        ),
      );
    });

    await super.update(entity, createOpLog: createOpLog);
  });
}