Transaction class
An EntityRepository transaction.
- Inheritance
-
- Object
- JsonEntityCacheSimple
- Transaction
- Implemented types
- Available Extensions
Constructors
- Transaction({bool autoCommit = false})
- Transaction.autoCommit()
- Transaction.executingOrNew({required bool autoCommit})
-
factory
Properties
- abortError → TransactionAbortedError?
-
Returns the abort error (TransactionAbortedError).
no setter
- allowEntityFetch → bool
-
If
true
it will allow the use of on repository to fetch an entity by an ID reference.no setteroverride - autoCommit → bool
-
Returns true if this transaction will automatically commit once
all operations have been executed.
final
-
cachedEntities
→ List<
Object> -
Returns all cached entities of this cache.
no setterinherited
- cachedEntitiesLength → int
-
Returns the total cached entities of this cache.
no setterinherited
- canPropagate → bool
-
Returns
canPropagate
of the mainOperation. See TransactionOperation.canPropagate.no setter - context → Object?
-
no setter
- duration → Duration?
-
The duration of the transaction execution.
no setter
- endTime → DateTime?
-
The time of transaction completion.
no setter
- error → Object?
-
no setter
-
executedOperations
→ List<
TransactionOperation> -
Returns the list of operations that were fully executed.
no setter
- executor → Object?
-
Returns the executor of this transaction.
no setter
-
extraErrors
→ List<
Object> ? -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → int
-
The cache ID.
finalinherited
- info → String
-
no setter
- initTime → DateTime?
-
The time of transaction initialization.
no setter
- isAborted → bool
-
Returns
true
if this transaction as aborted. See abort.no setter - isCommitted → bool
-
no setter
- isCommitting → bool
-
no setter
- isEmpty → bool
-
Returns
true
if this transaction doesn't have operations.no setter - isExecuting → bool
-
no setter
- isFinished → bool
-
no setter
- isNotEmpty → bool
-
Alias to ![isEmpty].
no setter
- isOpen → bool
-
Returns
true
if this transaction was open.no setter - isOpening → bool
-
Returns
true
if this transaction is in the middle of theopen
process.no setter - length → int
-
Returns the operations length.
no setter
- mainOperation → TransactionOperation?
-
Returns the 1st operations.
no setter
- notExecutedOperationsSize → int
-
no setter
-
operations
→ List<
TransactionOperation> -
no setter
- parentTransaction → Transaction?
-
final
- result → Object?
-
Returns the final result of this transaction.
no setter
- resultFuture → Future
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalCachedEntites → int
-
Returns the total number of cached entities.
no setterinherited
- transactionFuture → Future
-
no setter
- transactionResult ↔ FutureOr?
-
getter/setter pair
Methods
-
abort(
{String? reason, Object? payload, Object? error, StackTrace? stackTrace}) → FutureOr< TransactionAbortedError?> - Aborts this transaction.
-
addExecution<
R, C> (TransactionExecution< R, C> exec, {TransactionErrorResolver? errorResolver, Object? operation, String? debugInfo()?}) → FutureOr<R> -
addOperation(
TransactionOperation op) → void -
cacheEntities<
O> (List< O> entities, [dynamic idGetter(O o)?]) → void -
Caches the List
entities
. This is called by the entity decoder/loader. See cacheEntity.override -
cacheEntity<
O> (O entity, [dynamic idGetter(O o)?]) → void -
Caches
entity
. This is called by the entity decoder/loader. See cacheEntities.override -
clearCachedEntities(
) → void -
Clears all cached entities of this cache.
inherited
-
commit<
R> () → FutureOr< R?> - Commits this transaction, returning the final result.
-
dispose(
) → bool -
Disposes of the internals of this Transaction (only when isFinished).
Returns
true
if it was successfully disposed. -
execute<
R> (FutureOr< R> block()) → FutureOr<R?> -
Executes the transaction operations dispatches inside
block
then commits. -
executeOrError<
R> (FutureOr< R> block(), {required R onError(Transaction transaction, Object error, StackTrace stackTrace)}) → FutureOr<R> -
Executes the transaction operations dispatches inside
block
then commits. If any error occurs it returns the value returned byonError
. -
finishOperation<
R> (TransactionOperation op, R result, {bool allowAutoCommit = true}) → FutureOr< R> -
finishOperationVoid<
R> (TransactionOperation op, R result, {bool allowAutoCommit = true}) → void -
firstOperationWithEntity<
T extends TransactionOperationWithEntity> (Object entity) → T? -
getCachedEntities<
O> ({Type? type}) → Map< dynamic, Object> ? -
Returns the cached entities of
type
.inherited -
getCachedEntitiesByIDs<
O> (List ids, {Type? type, bool removeCachedIDs = false}) → Map< dynamic, Object> ? -
Returns the cached entities of
type
withids
.inherited -
getCachedEntityByID<
O> (dynamic id, {Type? type}) → O? -
Returns a cached entity of
type
withid
.inherited -
getCachedEntityByMapID<
O> (Map< Object?, Object?> map, {Type? type}) → O? -
Returns a cached entity of
type
with an id frommap
entries. See getEntityIDFromMap.inherited -
getEntityByID<
O> (dynamic id, {Type? type, bool sync = false, EntityResolutionRules? resolutionRules}) → FutureOr< O?> -
override
-
getEntityID<
O> (O object, {Type? type, dynamic idGetter(O o)?}) → Object? -
Returns the ID value from
object
fortype
.inherited -
getEntityIDFromMap(
Map< Object?, Object?> map, {Type? type}) → Object? -
Returns the ID value into
map
fortype
.inherited -
isCachedEntity<
O> (O entity, {Type? type, bool identicalEquality = true}) → bool -
Returns
true
ifentity
is cached.inherited -
isLastExecutingOperation(
TransactionOperation op) → bool -
Returns
true
ifop
is being executed. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyExecutionError<
R> (Object error, StackTrace stackTrace, {TransactionErrorResolver? errorResolver, Object? operation, String? debugInfo()?}) → FutureOr< R> -
onOpen<
R> (FutureOr< R> f()) → FutureOr<R> -
open(
FutureOr< Object> opener(), FutureOr<void> closer()?) → FutureOr<Object?> - Opens this transaction. This is called by the DBAdapter implementation.
-
operationsWithEntity<
T extends TransactionOperationWithEntity> (Object entity) → Iterable< T> -
removeCachedEntity<
O> (dynamic id, {Type? type}) → O? -
Removes an entity of
type
withid
of this cache.inherited -
toString(
{bool compact = false, bool withOperations = true, bool withExecutedOperations = true}) → String -
A string representation of this object.
override
-
waitAllExecuted(
) → FutureOr< bool> -
Waits for all
operation
s to execute. -
waitOperation(
TransactionOperation? operation, {TransactionOperation? parentOperation, Duration timeout = const Duration(seconds: 40)}) → Future< bool> -
Waits
operation
to be executed in this Transaction.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- executingTransaction → Transaction?
-
The current executing transaction.
See execute and executeBlock.
no setter
-
openInstances
→ List<
Transaction> -
Returns the
Transaction
that are open.no setter
Static Methods
-
executeBlock<
R> (FutureOr< R> block(Transaction transaction), {Transaction? transaction, bool allowExecutingTransaction = true}) → FutureOr<R> -
Executes
block
inside a Transaction and commits it. -
isFilteredError(
Object error, StackTrace stackTrace) → bool -
registerErrorFilter(
ErrorFilter errorFilter) → void