Snapshot
Extends:
Indirect Implements:
Snapshots present a read-only version of a specific state. As long as a snapshot is not aborted, the object store will reflect changes to the state in form of the differences to the originating state in the snapshot. This makes efficient queries against a fixed state possible without blocking other transactions to commit.
Constructor Summary
Protected Constructor | ||
protected |
constructor(objectStore: ObjectStore, backend: IObjectStore) This constructor should only be called by an ObjectStore object. |
Method Summary
Public Methods | ||
public |
abort(tx: *): Promise<boolean> Aborts a snapshot and stops updating its diff. |
|
public |
close(): Promise Alias for abort. |
|
public |
async commit(tx: *) Unsupported operation for snapshots. |
|
public |
async put(key: *, value: *): Promise Unsupported operation for snapshots. |
|
public |
putSync(key: *, value: *) Unsupported operation for snapshots. |
|
public |
async remove(key: *): Promise Unsupported operation for snapshots. |
|
public |
removeSync(key: *) Unsupported operation for snapshots. |
|
public |
snapshot() Unsupported operation for snapshots. |
|
public |
Unsupported operation for snapshots. |
|
public |
Unsupported operation for snapshots. |
|
public |
async truncate(): Promise Unsupported operation for snapshots. |
|
public |
Unsupported operation for snapshots. |
Protected Methods | ||
protected |
async _apply(tx: Transaction): Promise Internally applies a transaction to the snapshot state. |
|
protected |
async _commitBackend(): Promise<boolean> Commits the transaction to the backend. |
|
protected |
async _commitInternal(tx: Transaction): Promise Unsupported operation for snapshots. |
|
protected |
_isCommittable(tx: Transaction): boolean Unsupported operation for snapshots. |
|
protected |
inherit(tx: Transaction): * A specific set of changes can be assumed to be already applied by providing a Transaction or Snapshot. |
Inherited Summary
From class Transaction | ||
public get |
connected: boolean |
|
public get |
|
|
public get |
id: number |
|
public get |
A map of index names to indices. |
|
public get |
nested: boolean |
|
public get |
|
|
public get |
state: Transaction.STATE: * The transaction's current state. |
|
public |
async abort(tx: Transaction): Promise<boolean> Aborts a transaction and (if this was the last open transaction) potentially persists the most recent, committed state. |
|
public |
close(): Promise Alias for abort. |
|
public |
async commit(tx: Transaction): Promise<boolean> Commits a transaction to the underlying backend. |
|
public |
Returns the count of entries in the given range. |
|
public |
decode(value: *, key: string): * Method called to decode a single value. |
|
public |
encode(value: *): * Method called to encode a single value. |
|
public |
async get(key: string, options: RetrievalConfig): Promise<*> Returns a promise of the object stored under the given primary key. |
|
public |
Returns the index of the given name. |
|
public |
isSynchronous(): boolean Checks whether an object store implements the ISynchronousObjectStore interface. |
|
public |
async keyStream(callback: function(key: string): boolean, ascending: boolean, query: KeyRange): Promise Iterates over the keys in a given range and direction. |
|
public |
Returns a promise of a set of keys fulfilling the given query. |
|
public |
Returns a promise of the key being maximal for the given range. |
|
public |
Returns a promise of the object whose primary key is maximal for the given range. |
|
public |
Returns a promise of the key being minimal for the given range. |
|
public |
Returns a promise of the object whose primary key is minimal for the given range. |
|
public |
async put(key: string, value: *): Promise Inserts or replaces a key-value pair. |
|
public |
putSync(key: string, value: *) Inserts or replaces a key-value pair. |
|
public |
async remove(key: string): Promise Removes the key-value pair of the given key from the object store. |
|
public |
removeSync(key: string) Removes the key-value pair of the given key from the object store. |
|
public |
Creates an in-memory snapshot of this state. |
|
public |
synchronousTransaction(enableWatchdog: boolean): SynchronousTransaction Creates a nested synchronous transaction, ensuring read isolation. |
|
public |
toString(): string |
|
public |
toStringShort(): string |
|
public |
transaction(enableWatchdog: boolean): Transaction Creates a nested transaction, ensuring read isolation. |
|
public |
async truncate(): Promise Empties the object store. |
|
public |
async valueStream(callback: function(value: *, key: string): boolean, ascending: boolean, query: KeyRange): Promise Iterates over the keys and values in a given range and direction. |
|
public |
Returns a promise of an array of objects whose primary keys fulfill the given query. |
|
protected |
async _apply(tx: Transaction): Promise Internally applies a transaction to the transaction's state. This needs to be done in batch (as a db level transaction), i.e., either the full state is updated or no changes are applied. |
|
protected |
_applySync(tx: Transaction) Non-async version of _apply that does not update snapshots. |
|
protected |
async _checkConstraints(): Promise<boolean> Is used to check constraints before committing. |
|
protected |
async _commitBackend(): Promise<boolean> Commits the transaction to the backend. |
|
protected |
async _commitInternal(tx: Transaction): Promise Is used to commit the transaction to the in memory state. |
|
protected |
_isCommittable(tx: Transaction): boolean Is used to probe whether a transaction can be committed. |
|
protected |
_put(key: string, value: *) Internal method for inserting/replacing a key-value pair. |
|
protected |
_remove(key: string) Internal method for removing a key-value pair. |
|
protected |
_setParent(parent: *) Allows to change the backend of a Transaction when the state has been flushed. |
|
protected |
Non-async variant to empty the object store. |
Protected Constructors
protected constructor(objectStore: ObjectStore, backend: IObjectStore) source
This constructor should only be called by an ObjectStore object.
Override:
Transaction#constructorParams:
Name | Type | Attribute | Description |
objectStore | ObjectStore | The object store this transaction belongs to. |
|
backend | IObjectStore | The backend this transaction is based on. |
Public Methods
public abort(tx: *): Promise<boolean> source
Aborts a snapshot and stops updating its diff.
Override:
Transaction#abortParams:
Name | Type | Attribute | Description |
tx | * |
|
Return:
Promise<boolean> | A promise of the success outcome. |
public close(): Promise source
Alias for abort.
Override:
Transaction#closeReturn:
Promise | The promise resolves after successful abortion of the transaction. |
public async commit(tx: *) source
Unsupported operation for snapshots.
Override:
Transaction#commitParams:
Name | Type | Attribute | Description |
tx | * |
Throw:
* |
public async put(key: *, value: *): Promise source
Unsupported operation for snapshots.
Override:
Transaction#putParams:
Name | Type | Attribute | Description |
key | * | ||
value | * |
Return:
Promise |
public putSync(key: *, value: *) source
Unsupported operation for snapshots.
Override:
Transaction#putSyncParams:
Name | Type | Attribute | Description |
key | * | ||
value | * |
public async remove(key: *): Promise source
Unsupported operation for snapshots.
Override:
Transaction#removeParams:
Name | Type | Attribute | Description |
key | * |
Return:
Promise |
public removeSync(key: *) source
Unsupported operation for snapshots.
Override:
Transaction#removeSyncParams:
Name | Type | Attribute | Description |
key | * |
public synchronousTransaction() source
Unsupported operation for snapshots.
Override:
Transaction#synchronousTransactionpublic async truncate(): Promise source
Unsupported operation for snapshots.
Override:
Transaction#truncateReturn:
Promise |
Protected Methods
protected async _apply(tx: Transaction): Promise source
Internally applies a transaction to the snapshot state. In contrast to transactions, this tries to reflect the old state in the snapshot.
Override:
Transaction#_applyParams:
Name | Type | Attribute | Description |
tx | Transaction | The transaction to apply. |
Return:
Promise | The promise resolves after applying the transaction. |
protected async _commitBackend(): Promise<boolean> source
Commits the transaction to the backend.
Override:
Transaction#_commitBackendReturn:
Promise<boolean> | A promise of the success outcome. |
protected async _commitInternal(tx: Transaction): Promise source
Unsupported operation for snapshots.
Override:
Transaction#_commitInternalParams:
Name | Type | Attribute | Description |
tx | Transaction | The transaction to be applied. |
Return:
Promise | A promise that resolves upon successful application of the transaction. |
protected _isCommittable(tx: Transaction): boolean source
Unsupported operation for snapshots.
Override:
Transaction#_isCommittableParams:
Name | Type | Attribute | Description |
tx | Transaction |
|
The transaction to be applied, if not given checks for the this transaction. |
Return:
boolean | Whether a commit will be successful. |
protected inherit(tx: Transaction): * source
A specific set of changes can be assumed to be already applied by providing a Transaction or Snapshot. These differences will be inherited while the backend of the snapshot remains the current state. This is useful, if we have a transaction/snapshot to a previous state, which we do not want to commit. Then, we can still base our snapshot on this earlier state although the current backend is already ahead.
Params:
Name | Type | Attribute | Description |
tx | Transaction | A transaction or snapshot containing changes that have already been applied. |
Return:
* |