Home Reference Source Test
public interface | source

IObjectStore

Extends:

IReadableObjectStore → IObjectStore

Indirect Subclass:

ISynchronousObjectStore

Indirect 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.

Method Summary

Public Methods
public abstract

async put(key: string, value: *): Promise

Inserts or replaces a key-value pair.

public abstract

async remove(key: string): Promise

Removes the key-value pair of the given key from the object store.

public abstract

Creates a new synchronous transaction, ensuring read isolation on the most recently successfully committed state.

public abstract

transaction(enableWatchdog: boolean): Transaction

Creates a new transaction, ensuring read isolation on the most recently successfully committed state.

Inherited Summary

From class IReadableObjectStore
public get

connected: boolean

public get abstract

indices: Map<string, IIndex>

A map of index names to indices.

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 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 Methods

public abstract async put(key: string, value: *): Promise source

Inserts or replaces a key-value pair.

Params:

NameTypeAttributeDescription
key string

The primary key to associate the value with.

value *

The value to write.

Return:

Promise

The promise resolves after writing to the current object store finished.

public abstract async remove(key: string): Promise source

Removes the key-value pair of the given key from the object store.

Params:

NameTypeAttributeDescription
key string

The primary key to delete along with the associated object.

Return:

Promise

The promise resolves after writing to the current object store finished.

public abstract synchronousTransaction(enableWatchdog: boolean): SynchronousTransaction source

Creates a new synchronous transaction, ensuring read isolation on the most recently successfully committed state.

Params:

NameTypeAttributeDescription
enableWatchdog boolean
  • optional

Boolean allows to disable watchdog timer.

Return:

SynchronousTransaction

The transaction object.

public abstract transaction(enableWatchdog: boolean): Transaction source

Creates a new transaction, ensuring read isolation on the most recently successfully committed state.

Params:

NameTypeAttributeDescription
enableWatchdog boolean
  • optional

Boolean allows to disable watchdog timer.

Return:

Transaction

The transaction object.