create method
FutureOr<void>
create(
- PgrServiceModel entity, {
- bool createOpLog = true,
- DataOperation dataOperation = DataOperation.create,
override
The create
method creates a new entity.
Implementation
@override
FutureOr<void> create(
PgrServiceModel entity, {
bool createOpLog = true,
DataOperation dataOperation = DataOperation.create,
}) async {
return retryLocalCallOperation(() async {
final address = entity.address;
final complainant = entity.user;
final addressCompanion = address.companion;
final complainantCompanion = complainant.companion;
await sql.batch((batch) {
batch.insert(
sql.pgrService,
entity.companion,
mode: InsertMode.insertOrReplace,
);
batch.insert(
sql.pgrComplainant,
complainantCompanion,
mode: InsertMode.insertOrReplace,
);
batch.insert(
sql.address,
addressCompanion,
mode: InsertMode.insertOrReplace,
);
});
return super.create(
entity,
createOpLog: createOpLog,
dataOperation: dataOperation,
);
});
}