Transaction class

An EntityRepository transaction.

Inheritance
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
allCachedEntities → List<Object>
Returns all the cached entities of this cache. Calls instantiateAllCachedEntities before returning the cached entities.
no setterinherited
allowEntityFetch → bool
If true it will allow the use of on repository to fetch an entity by an ID reference.
no setteroverride
asEntityProvider → EntityProvider

Available on JsonEntityCache, provided by the JsonEntityCacheExtension extension

no setter
autoCommit → bool
Returns true if this transaction will automatically commit once all operations have been executed.
final
cachedEntities → List<Object>
Returns the already instantiated cached entities of this cache. See allCachedEntities.
no setterinherited
cachedEntitiesInstantiatorsLength → int
Returns the total cached entities instantiators of this cache. See cacheEntityInstantiator and totalCachedEntities.
no setterinherited
cachedEntitiesLength → int
Returns the total cached entities of this cache. See cacheEntity and totalCachedEntities.
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 the open 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
no setterinherited
totalCachedEntities → int
Returns the total number of cached entities and cache entities instantiators.
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
cacheEntityInstantiator<O>(Object id, O entityInstantiator(), {Type? type, bool overwrite = true}) → bool
Caches an entityInstantiator. This is called by the entity decoder/loader. See cacheEntity.
inherited
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 by onError.
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, bool instantiate = true}) → Map<dynamic, Object>?
Returns the cached entities of type.
inherited
getCachedEntitiesByIDs<O>(List ids, {Type? type, bool instantiate = true, bool removeCachedIDs = false}) → Map<dynamic, Object>?
Returns the cached entities of type with ids.
inherited
getCachedEntityByID<O>(dynamic id, {Type? type, dynamic instantiate = true}) → O?
Returns a cached entity of type with id.
inherited
getCachedEntityByMapID<O>(Map<Object?, Object?> map, {Type? type, dynamic instantiate = true}) → O?
Returns a cached entity of type with an id from map 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 for type.
inherited
getEntityIDFromMap(Map<Object?, Object?> map, {Type? type}) → Object?
Returns the ID value into map for type.
inherited
instantiateAllCachedEntities() → int
Instantiate all the entities, calling their entity instantiators. See cacheEntityInstantiator
inherited
isCachedEntity<O>(O entity, {Type? type, bool identicalEquality = true, dynamic idGetter(O o)?}) → bool
Returns true if entity is cached.
inherited
isCachedEntityByID<O>(dynamic id, {Type? type}) → bool
Returns a cached entity of type with id.
inherited
isLastExecutingOperation(TransactionOperation op) → bool
Returns true if op 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, bool instantiate = true}) → O?
Removes an entity of type with id 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 operations 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