create method

  1. @override
FutureOr<void> create(
  1. ProjectResourceModel entity, {
  2. bool createOpLog = false,
  3. DataOperation dataOperation = DataOperation.create,
})
override

The create method creates a new entity.

Implementation

@override
FutureOr<void> create(
  ProjectResourceModel entity, {
  bool createOpLog = false,
  DataOperation dataOperation = DataOperation.create,
}) async {
  return retryLocalCallOperation(() async {
    final projectProductVariantCompanion =
        entity.resource.copyWith(auditDetails: entity.auditDetails).companion;

    await sql.batch((batch) async {
      batch.insert(
        sql.projectResource,
        entity.companion,
        mode: InsertMode.insertOrReplace,
      );

      batch.insert(
        sql.projectProductVariant,
        projectProductVariantCompanion,
        mode: InsertMode.insertOrReplace,
      );
    });

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