Helper classes - WriteResult
Entity write result
The entity database will return type-safe results for write operations. There are four main write results, one for each type of write operation. Each of these operations is of type EntityWriteResult
.
In all cases, the records in the result will be a generated entity that matches the input. So, for inserting a Trade
instance, the database will return a result of type InsertResult<Trade>
where the property record
will be of type Trade
.
InsertResult
DeleteResult
ModifyResult
UpsertResult
; either anInsertResult
or aModifyResult
InsertResult
The InsertResult
has a single property record
which is the inserted record. This includes any generated values.
DeleteResult
The DeleteResult
has a single property record
which is the record as it was in the database before it was deleted.
ModifyResult
The ModifyResult
is slightly more complex. It has three properties:
- a
record
property, which is the record in the database after the modify operation - a
previous
property, which is the record as it was before the modify operation - a
modifiedFields
property, which holds aSet<String>
of the fields that were changed in the modify
UpsertResult
This could be either an InsertResult
or a ModifyResult
.
Write result
This is a single catch-all type for results of a write operation when using generated repositories or RxDb.
This type has the following fields:
savedRecords
- the saved recordsremovedRecords
- the deleted recordsmodifiedFields
- the updated fieldsnumRecordsDeleted
- the number of records deletedisError
- there was an error during the database operation. Needs to be checked whenValidationMode.LEGACY
is usederrorText
- the error description. Needs to be checked whenValidationMode.LEGACY
is used
Using RxDb
instead of entityDb or generated repositories will circumvent compile-time validation of database interactions. This means that errors might not appear until runtime or might lead to unexpected results.