Home Reference Source Test
public class | source

TransactionIndex

Extends:

InMemoryIndex → TransactionIndex

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

async count(query: KeyRange): Promise<number>

Returns the count of entries, whose secondary key is in the given range.

public

async keys(query: KeyRange, limit: number): Promise<Set<string>>

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

async maxKeys(query: KeyRange): Promise<Set<*>>

Returns a promise of a set of primary keys, whose associated secondary keys are maximal for the given range.

public

async maxValues(query: KeyRange): Promise<Array<*>>

Returns a promise of an array of objects whose secondary key is maximal for the given range.

public

async minKeys(query: KeyRange): Promise<Set<*>>

Returns a promise of a set of primary keys, whose associated secondary keys are minimal for the given range.

public

async minValues(query: KeyRange): Promise<Array<*>>

Returns a promise of an array of objects whose secondary key is minimal for the given range.

public

async values(query: KeyRange, limit: number): Promise<Array<*>>

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

async count(query: KeyRange): Promise<number>

Returns the count of entries, whose secondary key is in the given range.

public

keyStream(callback: function(key: string): boolean, ascending: boolean, query: KeyRange): Promise

Iterates over the primary keys in a given range of secondary keys and direction.

public

async keys(query: KeyRange, limit: number): Promise<Set<string>>

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

async maxKeys(query: KeyRange): Promise<Set<*>>

Returns a promise of a set of primary keys, whose associated secondary keys are maximal for the given range.

public

async maxValues(query: KeyRange): Promise<Array<*>>

Returns a promise of an array of objects whose secondary key is maximal for the given range.

public

async minKeys(query: KeyRange): Promise<Set<*>>

Returns a promise of a set of primary keys, whose associated secondary keys are minimal for the given range.

public

async minValues(query: KeyRange): Promise<Array<*>>

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

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

async values(query: KeyRange, limit: number): Promise<Array<*>>

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:

NameTypeAttributeDescription
objectStore Transaction

The transaction the index should be based on.

backend IObjectStore

The backend underlying the transaction.

Return:

Map<string, TransactionIndex>

A map containing all indices for 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#constructor

Params:

NameTypeAttributeDescription
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
  • optional

Whether the indexed attribute is considered to be iterable or not.

unique boolean
  • optional

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:

NameTypeAttributeDescription
key *
value *
isInStore boolean
  • optional

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#count

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

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#keys

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check the secondary keys against.

limit number
  • optional

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#maxKeys

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

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#maxValues

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

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#minKeys

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

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#minValues

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

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#values

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check secondary keys against.

limit number
  • optional

Limits the number of results if given.

Return:

Promise<Array<*>>

A promise of the array of objects relevant to the query.