Interface AsyncWritableStore<ItemType, IDType>

An asynchronous store that accepts changes to it's contents.

interface AsyncWritableStore<ItemType, IDType> {
    add(item, options?): Promise<void | ItemType>;
    get(id, options?): Promise<undefined | ItemType>;
    getIdentity?(item): undefined | IDType;
    getMetadata(): Promise<Metadata>;
    id: undefined | string;
    idProperty?: string;
    on?<Name>(eventName, callback): EventHandle;
    on?(eventName, callback): EventHandle;
    on?(eventName, callback): EventHandle;
    put(item, options?): Promise<void | ItemType>;
    query(query?, options?): AsyncQueryResult<ItemType>;
    remove(id): Promise<void>;
}

Type Parameters

Hierarchy (view full)

Implemented by

Properties

id: undefined | string

ID of the store.

idProperty?: string

Name of the property used as ID. If not provided, the 'getIdentity' method must be declared.

Methods

  • Create a new item. Throws an error, if the item already exists. The 'overwrite' option is assumed to be false).

    Parameters

    Returns Promise<void | ItemType>

  • Retrieves an item by its identifier.

    Parameters

    • id: IDType

      id of an item in the store.

    • Optional options: GetOptions

      options to specify the result.

    Returns Promise<undefined | ItemType>

  • Returns an items‘s identity. This must always execute synchronously.

    Parameters

    Returns undefined | IDType

    the ID

  • Returns any available metadata about the store. This may include attribution, available fields, cache directives, history or version information.

    Returns Promise<Metadata>

  • Register event listener for specific events.

    Type Parameters

    • Name extends "changed"

    Parameters

    • eventName: Name

      name of the event

    • callback: EventCallback<StoreEvents<IDType>[Name]>

      the event handler callback will be invoked when the event has been emitted

    Returns EventHandle

    a handle to unregister from the event

  • Register event listener for any event.

    Parameters

    • eventName: "*"

      must be "*" for this overload

    • callback: EventCallback<StoreChangedEvent<IDType>>

      the event handler callback will be invoked when any event has been emitted

    Returns EventHandle

    a handle to unregister from the events

  • Register event listener for the events listed in eventName. Comma separated event names are possible, for example "eventA,eventB".

    Parameters

    • eventName: string | string[]

      the event name or list of names

    • callback: EventCallback<unknown>

      the event handler callback

    Returns EventHandle

    a handle to unregister from the event(s)

  • Saves the given item. Depending on the specified options, a new item is created or a given item is updated.

    Parameters

    Returns Promise<void | ItemType>

  • Delete an item by id.

    Parameters

    • id: IDType

      id of item to delete

    Returns Promise<void>

Generated using TypeDoc