InMemoryBackend
Implements:
Transactions are created by calling the transaction method on an ObjectStore object. Transactions ensure read-isolation. On a given state, only one transaction can be committed successfully. Other transactions based on the same state will end up in a conflicted state if committed. Transactions opened after the successful commit of another transaction will be based on the new state and hence can be committed again.
Constructor Summary
Public Constructor | ||
public |
|
Method Summary
Public Methods | ||
public |
async applyCombined(tx: Transaction): function(): Promise> Returns the necessary information in order to flush a combined transaction. |
|
public |
|
|
public |
createIndex(indexName: string, keyPath: string | Array<string>, options: IndexConfig) |
|
public |
decode(value: *, key: string): * Method called to decode a single value. |
|
public |
deleteIndex(indexName: *, options: function(oldVersion: number, newVersion: number): boolean}) Deletes a secondary index from the object store. |
|
public |
encode(value: *): * Method called to encode a single value. |
|
public |
get(key: string, options: RetrievalConfig): Promise<*> |
|
public abstract |
getSync(key: string, options: SyncRetrievalConfig): * Returns the object stored under the given primary key. |
|
public |
|
|
public |
isCached(key: string): boolean A check whether a certain key is cached. |
|
public |
isSynchronous(): boolean Checks whether an object store implements the ISynchronousObjectStore interface. |
|
public |
Iterates over the keys in a given range and direction. |
|
public |
|
|
public |
async map(func: function(key: string, value: *)): Promise |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
async truncate(): Promise |
|
public |
|
|
public |
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 |
|
Protected Methods | ||
protected |
async _apply(tx: Transaction): Promise<boolean> |
Public Constructors
public constructor() source
Public Methods
public async applyCombined(tx: Transaction): function(): Promise> source
Returns the necessary information in order to flush a combined transaction.
Params:
Name | Type | Attribute | Description |
tx | Transaction | The transaction that should be applied to this backend. |
Return:
function(): Promise> | Either the tableName if this is a native, persistent backend or a function that effectively applies the transaction to non-persistent backends. |
public async count(query: KeyRange): Promise<number> source
Params:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<number> |
public createIndex(indexName: string, keyPath: string | Array<string>, options: IndexConfig) source
Params:
Name | Type | Attribute | Description |
indexName | string | The name of the index. |
|
keyPath | string | Array<string> |
|
The path to the key within the object. May be an array for multiple levels. |
options | IndexConfig |
|
An options object. |
public decode(value: *, key: string): * source
Method called to decode a single value.
Params:
Name | Type | Attribute | Description |
value | * | Value to be decoded. |
|
key | string | Key corresponding to the value. |
Return:
* | The decoded value. |
public deleteIndex(indexName: *, options: function(oldVersion: number, newVersion: number): boolean}) source
Deletes a secondary index from the object store.
Params:
Name | Type | Attribute | Description |
indexName | * | ||
options | function(oldVersion: number, newVersion: number): boolean} |
|
public encode(value: *): * source
Method called to encode a single value.
Params:
Name | Type | Attribute | Description |
value | * | Value to be encoded. |
Return:
* | The encoded value. |
public get(key: string, options: RetrievalConfig): Promise<*> source
Params:
Name | Type | Attribute | Description |
key | string | ||
options | RetrievalConfig |
|
Advanced retrieval options. |
Return:
Promise<*> |
public abstract getSync(key: string, options: SyncRetrievalConfig): * source
Returns the object stored under the given primary key. Resolves to undefined if the key is not present in the object store.
Params:
Name | Type | Attribute | Description |
key | string | The primary key to look for. |
|
options | SyncRetrievalConfig |
|
Advanced retrieval options. |
Return:
* | The object stored under the given key, or undefined if not present. |
public index(indexName: string): IIndex source
Params:
Name | Type | Attribute | Description |
indexName | string |
public isCached(key: string): boolean source
A check whether a certain key is cached.
Params:
Name | Type | Attribute | Description |
key | string | The key to check. |
Return:
boolean | A boolean indicating whether the key is already in the cache. |
public isSynchronous(): boolean source
Checks whether an object store implements the ISynchronousObjectStore interface.
Return:
boolean | The transaction object. |
public keyStream(callback: function(key: string): boolean, ascending: boolean, query: KeyRange): Promise source
Iterates over the keys in a given range and direction. The callback is called for each primary key fulfilling the query until it returns false and stops the iteration.
Params:
Name | Type | Attribute | Description |
callback | function(key: string): boolean | A predicate called for each key until returning false. |
|
ascending | boolean | Determines the direction of traversal. |
|
query | KeyRange | An optional KeyRange to narrow down the iteration space. |
Return:
Promise | The promise resolves after all elements have been streamed. |
public keys(query: Query | KeyRange, limit: number): Promise<Set<string>> source
Return:
Promise<Set<string>> |
public async map(func: function(key: string, value: *)): Promise source
Params:
Name | Type | Attribute | Description |
func | function(key: string, value: *) |
Return:
Promise |
public async maxKey(query: KeyRange): Promise<string> source
Params:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<string> |
public async maxValue(query: KeyRange): Promise<*> source
Params:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<*> |
public async minKey(query: KeyRange): Promise<string> source
Params:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<string> |
public async minValue(query: KeyRange): Promise<*> source
Params:
Name | Type | Attribute | Description |
query | KeyRange |
|
Return:
Promise<*> |
public truncateSync() source
public valueStream(callback: function(value: *, key: string): boolean, ascending: boolean, query: KeyRange): Promise source
Iterates over the keys and values in a given range and direction. The callback is called for each value and primary key fulfilling the query until it returns false and stops the iteration.
Params:
Name | Type | Attribute | Description |
callback | function(value: *, key: string): boolean | A predicate called for each value and key until returning false. |
|
ascending | boolean | Determines the direction of traversal. |
|
query | KeyRange | An optional KeyRange to narrow down the iteration space. |
Return:
Promise | The promise resolves after all elements have been streamed. |
public async values(query: Query | KeyRange, limit: number): Promise<Array<*>> source
Return:
Promise<Array<*>> |
Protected Methods
protected async _apply(tx: Transaction): Promise<boolean> source
Params:
Name | Type | Attribute | Description |
tx | Transaction |
Return:
Promise<boolean> |