create method
FutureOr<void>
create(
- HouseholdModel entity, {
- bool createOpLog = true,
- DataOperation dataOperation = DataOperation.create,
override
The create
method creates a new entity.
Implementation
@override
FutureOr<void> create(
HouseholdModel entity, {
bool createOpLog = true,
DataOperation dataOperation = DataOperation.create,
}) async {
retryLocalCallOperation(() async {
final householdCompanion = entity.companion;
final localityCompanion = entity.address?.locality?.companion;
final addressCompanion = entity.address?.companion;
await sql.batch((batch) async {
batch.insert(
sql.household,
householdCompanion,
mode: InsertMode.insertOrReplace,
);
if (addressCompanion != null) {
batch.insert(
sql.address,
addressCompanion,
mode: InsertMode.insertOrReplace,
);
}
if (localityCompanion != null) {
batch.insert(
sql.locality,
localityCompanion,
mode: InsertMode.insertOrReplace,
);
}
});
await super.create(entity, createOpLog: createOpLog);
});
}