TransactionIndex
Extends:
Indirect Implements:
This class constitutes an InMemoryIndex for Transactions. It unifies the results of keys changed during the transaction with the underlying backend.
Static Method Summary
Static Public Methods | ||
public static |
derive(objectStore: Transaction, backend: IObjectStore): Map<string, TransactionIndex> Derives the indices from the backend and returns a new map of transactions. |
Constructor Summary
Protected Constructor | ||
protected |
constructor(objectStore: Transaction, backend: IObjectStore, keyPath: string | Array<string>, multiEntry: boolean, unique: boolean) Constructs a new TransactionIndex serving the transaction's changes and unifying the results with the underlying backend. |
Method Summary
Public Methods | ||
public |
async checkUniqueConstraint(key: *, value: *, isInStore: boolean): Promise<void> Checks for a violation of a unique constraint depending on whether the pair is already in the store or not. |
|
public |
Returns the count of entries, whose secondary key is in the given range. |
|
public |
Returns a promise of a set of primary keys, whose associated objects' secondary keys are in the given range. If the optional query is not given, it returns all primary keys in the index. If the query is of type KeyRange, it returns all primary keys for which the secondary key is within this range. |
|
public |
Returns a promise of a set of primary keys, whose associated secondary keys are maximal for the given range. |
|
public |
Returns a promise of an array of objects whose secondary key is maximal for the given range. |
|
public |
Returns a promise of a set of primary keys, whose associated secondary keys are minimal for the given range. |
|
public |
Returns a promise of an array of objects whose secondary key is minimal for the given range. |
|
public |
Returns a promise of an array of objects whose secondary keys fulfill the given query. |
Inherited Summary
From class InMemoryIndex | ||
public get |
keyPath: string | Array<string> The key path associated with this index. |
|
public get |
multiEntry: boolean This value determines whether the index supports multiple secondary keys per entry. |
|
public get |
unique: boolean This value determines whether the index is a unique constraint. |
|
public |
Returns the count of entries, whose secondary key is in the given range. |
|
public |
Iterates over the primary keys in a given range of secondary keys and direction. |
|
public |
Returns a promise of a set of primary keys, whose associated objects' secondary keys are in the given range. If the optional query is not given, it returns all primary keys in the index. If the query is of type KeyRange, it returns all primary keys for which the secondary key is within this range. |
|
public |
Returns a promise of a set of primary keys, whose associated secondary keys are maximal for the given range. |
|
public |
Returns a promise of an array of objects whose secondary key is maximal for the given range. |
|
public |
Returns a promise of a set of primary keys, whose associated secondary keys are minimal for the given range. |
|
public |
Returns a promise of an array of objects whose secondary key is minimal for the given range. |
|
public |
put(key: string, value: *, oldValue: *) Inserts a new key-value pair into the index. |
|
public |
remove(key: string, oldValue: *) Removes a key-value pair from the index. |
|
public |
truncate() Reinitialises the index. |
|
public |
async valueStream(callback: function(value: *, key: string): boolean, ascending: boolean, query: KeyRange): Promise Iterates over the values of the store in a given range of secondary keys and direction. |
|
public |
Returns a promise of an array of objects whose secondary keys fulfill the given query. |
|
protected |
async _retrieveValues(keys: Set<string>): Promise<Array<*>> A helper method to retrieve the values corresponding to a set of keys. |
Static Public Methods
public static derive(objectStore: Transaction, backend: IObjectStore): Map<string, TransactionIndex> source
Derives the indices from the backend and returns a new map of transactions.
Params:
Name | Type | Attribute | Description |
objectStore | Transaction | The transaction the index should be based on. |
|
backend | IObjectStore | The backend underlying the transaction. |
Protected Constructors
protected constructor(objectStore: Transaction, backend: IObjectStore, keyPath: string | Array<string>, multiEntry: boolean, unique: boolean) source
Constructs a new TransactionIndex serving the transaction's changes and unifying the results with the underlying backend.
Override:
InMemoryIndex#constructorParams:
Name | Type | Attribute | Description |
objectStore | Transaction | The transaction the index should be based on. |
|
backend | IObjectStore | The backend underlying the transaction. |
|
keyPath | string | Array<string> | The key path of the indexed attribute. |
|
multiEntry | boolean |
|
Whether the indexed attribute is considered to be iterable or not. |
unique | boolean |
|
Whether there is a unique constraint on the attribute. |
Public Methods
public async checkUniqueConstraint(key: *, value: *, isInStore: boolean): Promise<void> source
Checks for a violation of a unique constraint depending on whether the pair is already in the store or not.
Params:
Name | Type | Attribute | Description |
key | * | ||
value | * | ||
isInStore | boolean |
|
Return:
Promise<void> |
public async count(query: KeyRange): Promise<number> source
Returns the count of entries, whose secondary key is in the given range. If the optional query is not given, it returns the count of entries in the index. If the query is of type KeyRange, it returns the count of entries, whose secondary key is within the given range.
Override:
InMemoryIndex#countParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<number> |
public async keys(query: KeyRange, limit: number): Promise<Set<string>> source
Returns a promise of a set of primary keys, whose associated objects' secondary keys are in the given range. If the optional query is not given, it returns all primary keys in the index. If the query is of type KeyRange, it returns all primary keys for which the secondary key is within this range.
Override:
InMemoryIndex#keysParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check the secondary keys against. |
limit | number |
|
Limits the number of results if given. |
Return:
Promise<Set<string>> | A promise of the set of primary keys relevant to the query. |
public async maxKeys(query: KeyRange): Promise<Set<*>> source
Returns a promise of a set of primary keys, whose associated secondary keys are maximal for the given range. If the optional query is not given, it returns the set of primary keys, whose associated secondary key is maximal within the index. If the query is of type KeyRange, it returns the set of primary keys, whose associated secondary key is maximal for the given range.
Override:
InMemoryIndex#maxKeysParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check keys against. |
Return:
Promise<Set<*>> | A promise of the key relevant to the query. |
public async maxValues(query: KeyRange): Promise<Array<*>> source
Returns a promise of an array of objects whose secondary key is maximal for the given range. If the optional query is not given, it returns the objects whose secondary key is maximal within the index. If the query is of type KeyRange, it returns the objects whose secondary key is maximal for the given range.
Override:
InMemoryIndex#maxValuesParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check keys against. |
Return:
Promise<Array<*>> | A promise of array of objects relevant to the query. |
public async minKeys(query: KeyRange): Promise<Set<*>> source
Returns a promise of a set of primary keys, whose associated secondary keys are minimal for the given range. If the optional query is not given, it returns the set of primary keys, whose associated secondary key is minimal within the index. If the query is of type KeyRange, it returns the set of primary keys, whose associated secondary key is minimal for the given range.
Override:
InMemoryIndex#minKeysParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check keys against. |
Return:
Promise<Set<*>> | A promise of the key relevant to the query. |
public async minValues(query: KeyRange): Promise<Array<*>> source
Returns a promise of an array of objects whose secondary key is minimal for the given range. If the optional query is not given, it returns the objects whose secondary key is minimal within the index. If the query is of type KeyRange, it returns the objects whose secondary key is minimal for the given range.
Override:
InMemoryIndex#minValuesParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check keys against. |
Return:
Promise<Array<*>> | A promise of array of objects relevant to the query. |
public async values(query: KeyRange, limit: number): Promise<Array<*>> source
Returns a promise of an array of objects whose secondary keys fulfill the given query. If the optional query is not given, it returns all objects in the index. If the query is of type KeyRange, it returns all objects whose secondary keys are within this range.
Override:
InMemoryIndex#valuesParams:
Name | Type | Attribute | Description |
query | KeyRange |
|
Optional query to check secondary keys against. |
limit | number |
|
Limits the number of results if given. |
Return:
Promise<Array<*>> | A promise of the array of objects relevant to the query. |