create method
FutureOr<void>
create(
- ServiceDefinitionModel entity, {
- bool createOpLog = false,
- DataOperation dataOperation = DataOperation.create,
override
The create
method creates a new entity.
Implementation
@override
FutureOr<void> create(
ServiceDefinitionModel entity, {
bool createOpLog = false,
DataOperation dataOperation = DataOperation.create,
}) async {
return retryLocalCallOperation(() async {
final serviceDefinitionCompanion = entity.companion;
final attributes = entity.attributes;
await sql.batch((batch) {
batch.insert(
sql.serviceDefinition,
serviceDefinitionCompanion,
mode: InsertMode.insertOrReplace,
);
if (attributes != null) {
final attributesCompanions = attributes.map((e) {
return e.companion;
}).toList();
batch.insertAll(
sql.attributes,
attributesCompanions,
mode: InsertMode.insertOrReplace,
);
}
});
await super.create(entity, createOpLog: false);
});
}