Home Reference Source Test
public interface | source

IReadableObjectStore

Direct Subclass:

IBackend, IObjectStore

Direct Implemented:

This interface represents an object store (roughly corresponding to a table in a relational database). It stores key-value pairs where the key is generally considered to be a string and the value is any object. The key is the entry's primary key. Other keys within the object may be accessed by indices as offered by the store.

Member Summary

Public Members
public get

connected: boolean

public get abstract

indices: Map<string, IIndex>

A map of index names to indices.

Method Summary

Public Methods
public abstract

async close(): Promise

Closes the object store and potential connections.

public abstract

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

Returns the count of entries in the given range.

public abstract

decode(value: *, key: string): *

Method called to decode a single value.

public abstract

encode(value: *): *

Method called to encode a single value.

public abstract

async get(key: string, options: RetrievalConfig): Promise<*>

Returns a promise of the object stored under the given primary key.

public abstract

index(indexName: string): IIndex

Returns the index of the given name.

public abstract

isSynchronous(): boolean

Checks whether an object store implements the ISynchronousObjectStore interface.

public abstract

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

Iterates over the keys in a given range and direction.

public abstract

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

Returns a promise of a set of keys fulfilling the given query.

public abstract

async maxKey(query: KeyRange): Promise<string>

Returns a promise of the key being maximal for the given range.

public abstract

async maxValue(query: KeyRange): Promise<*>

Returns a promise of the object whose primary key is maximal for the given range.

public abstract

async minKey(query: KeyRange): Promise<string>

Returns a promise of the key being minimal for the given range.

public abstract

async minValue(query: KeyRange): Promise<*>

Returns a promise of the object whose primary key is minimal for the given range.

public abstract

async truncate(): Promise

Empties the object store.

public abstract

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 abstract

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

Returns a promise of an array of objects whose primary keys fulfill the given query.

Protected Methods
protected abstract

async _apply(tx: Transaction): Promise

Internally applies a transaction to the store'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.

Public Members

public get connected: boolean source

public get abstract indices: Map<string, IIndex> source

A map of index names to indices. The index names can be used to access an index.

Public Methods

public abstract async close(): Promise source

Closes the object store and potential connections.

Return:

Promise

The promise resolves after closing the object store.

public abstract async count(query: KeyRange): Promise<number> source

Returns the count of entries in the given range. If the optional query is not given, it returns the count of entries in the object store. If the query is of type KeyRange, it returns the count of entries within the given range.

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Return:

Promise<number>

public abstract decode(value: *, key: string): * source

Method called to decode a single value.

Params:

NameTypeAttributeDescription
value *

Value to be decoded.

key string

Key corresponding to the value.

Return:

*

The decoded value.

public abstract encode(value: *): * source

Method called to encode a single value.

Params:

NameTypeAttributeDescription
value *

Value to be encoded.

Return:

*

The encoded value.

public abstract async get(key: string, options: RetrievalConfig): Promise<*> source

Returns a promise of the object stored under the given primary key. Resolves to undefined if the key is not present in the object store.

Params:

NameTypeAttributeDescription
key string

The primary key to look for.

options RetrievalConfig
  • optional

Advanced retrieval options.

Return:

Promise<*>

A promise of the object stored under the given key, or undefined if not present.

public abstract index(indexName: string): IIndex source

Returns the index of the given name. If the index does not exist, it returns undefined.

Params:

NameTypeAttributeDescription
indexName string

The name of the requested index.

Return:

IIndex

The index associated with the given name.

public abstract isSynchronous(): boolean source

Checks whether an object store implements the ISynchronousObjectStore interface.

Return:

boolean

The transaction object.

public abstract 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:

NameTypeAttributeDescription
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 abstract async keys(query: Query | KeyRange, limit: number): Promise<Set<string>> source

Returns a promise of a set of keys fulfilling the given query. If the optional query is not given, it returns all keys in the object store. If the query is of type KeyRange, it returns all keys of the object store being within this range. If the query is of type Query, it returns all keys fulfilling the query.

Params:

NameTypeAttributeDescription
query Query | KeyRange
  • optional

Optional query to check keys against.

limit number
  • optional

Limits the number of results if given.

Return:

Promise<Set<string>>

A promise of the set of keys relevant to the query.

public abstract async maxKey(query: KeyRange): Promise<string> source

Returns a promise of the key being maximal for the given range. If the optional query is not given, it returns the maximal key. If the query is of type KeyRange, it returns the key being maximal for the given range.

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check keys against.

Return:

Promise<string>

A promise of the key relevant to the query.

public abstract async maxValue(query: KeyRange): Promise<*> source

Returns a promise of the object whose primary key is maximal for the given range. If the optional query is not given, it returns the object whose key is maximal. If the query is of type KeyRange, it returns the object whose primary key is maximal for the given range.

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check keys against.

Return:

Promise<*>

A promise of the object relevant to the query.

public abstract async minKey(query: KeyRange): Promise<string> source

Returns a promise of the key being minimal for the given range. If the optional query is not given, it returns the minimal key. If the query is of type KeyRange, it returns the key being minimal for the given range.

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check keys against.

Return:

Promise<string>

A promise of the key relevant to the query.

public abstract async minValue(query: KeyRange): Promise<*> source

Returns a promise of the object whose primary key is minimal for the given range. If the optional query is not given, it returns the object whose key is minimal. If the query is of type KeyRange, it returns the object whose primary key is minimal for the given range.

Params:

NameTypeAttributeDescription
query KeyRange
  • optional

Optional query to check keys against.

Return:

Promise<*>

A promise of the object relevant to the query.

public abstract async truncate(): Promise source

Empties the object store.

Return:

Promise

The promise resolves after emptying the object store.

public abstract 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:

NameTypeAttributeDescription
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 resolved after all elements have been streamed.

public abstract async values(query: Query | KeyRange, limit: number): Promise<Array<*>> source

Returns a promise of an array of objects whose primary keys fulfill the given query. If the optional query is not given, it returns all objects in the object store. If the query is of type KeyRange, it returns all objects whose primary keys are within this range. If the query is of type Query, it returns all objects whose primary keys fulfill the query.

Params:

NameTypeAttributeDescription
query Query | KeyRange
  • optional

Optional query to check 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.

Protected Methods

protected abstract async _apply(tx: Transaction): Promise source

Internally applies a transaction to the store'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.

Params:

NameTypeAttributeDescription
tx Transaction

The transaction to apply.

Return:

Promise

The promise resolves after applying the transaction.