Home Reference Source Test
public interface | source

IBackend

Extends:

IReadableObjectStore → IBackend

Direct Implemented:

This interface provides the methods specific to backends.

Method Summary

Public Methods
public abstract

async applyCombined(tx: Transaction): function(): Promise>

Returns the necessary information in order to flush a combined transaction.

public abstract

createIndex(indexName: string, keyPath: string | Array<string>, options: IndexConfig)

Creates a new secondary index on the object store.

public abstract

deleteIndex(indexName: *, options: function(oldVersion: number, newVersion: number): boolean})

Deletes a secondary index from the object store.

public abstract

isSynchronous(): boolean

Checks whether an object store implements the ISynchronousObjectStore interface.

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 applyCombined(tx: Transaction): function(): Promise> source

Returns the necessary information in order to flush a combined transaction.

Params:

NameTypeAttributeDescription
tx Transaction

The transaction that should be applied to this backend.

Return:

function(): Promise>

For non-persistent backends: a function that effectively applies the transaction. Native backends otherwise specify their own information as needed by their JungleDB instance.

public abstract createIndex(indexName: string, keyPath: string | Array<string>, options: IndexConfig) source

Creates a new secondary index on the object store. Currently, all secondary indices are non-unique. They are defined by a key within the object or alternatively a path through the object to a specific subkey. For example, ['a', 'b'] could be used to use 'key' as the key in the following object: { 'a': { 'b': 'key' } } Secondary indices may be multiEntry, i.e., if the keyPath resolves to an iterable object, each item within can be used to find this entry. If a new object does not possess the key path associated with that index, it is simply ignored.

This function may only be called before the database is connected. Moreover, it is only executed on database version updates or on first creation.

Params:

NameTypeAttributeDescription
indexName string

The name of the index.

keyPath string | Array<string>
  • optional

The path to the key within the object. May be an array for multiple levels.

options IndexConfig
  • optional

An options object.

public abstract deleteIndex(indexName: *, options: function(oldVersion: number, newVersion: number): boolean}) source

Deletes a secondary index from the object store.

Params:

NameTypeAttributeDescription
indexName *
options function(oldVersion: number, newVersion: number): boolean}
  • optional

public abstract isSynchronous(): boolean source

Checks whether an object store implements the ISynchronousObjectStore interface.

Override:

IReadableObjectStore#isSynchronous

Return:

boolean

The transaction object.