Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IDataConnector<T, U, V, W>

The description of a general purpose data connector.

Type parameters

  • T

    The basic entity response type a service's connector.

  • U = T

    The basic entity request type, which is conventionally the same as the response type but may be different if a service's implementation requires input data to be different from output responses. Defaults to T.

  • V = string

    The basic token applied to a request, conventionally a string ID or filter, but may be set to a different type when an implementation requires it. Defaults to string.

  • W = string

    The type of the optional query parameter of the list method. Defaults to string;

Hierarchy

Implemented by

Index

Methods

Methods

fetch

  • fetch(id: V): Promise<T>
  • Retrieve an item from the data connector.

    Parameters

    • id: V

      The identifier used to retrieve an item.

    Returns Promise<T>

    A promise that bears a data payload if available.

    Notes

    The promise returned by this method may be rejected if an error occurs in retrieving the data. Nonexistence of an id resolves with undefined.

list

  • list(query?: W): Promise<{ ids: V[]; values: T[] }>
  • Retrieve the list of items available from the data connector.

    Parameters

    • Optional query: W

      The optional query filter to apply to the connector request.

    Returns Promise<{ ids: V[]; values: T[] }>

    A promise that bears a list of values and an associated list of fetch ids.

    Notes

    The promise returned by this method may be rejected if an error occurs in retrieving the data. The two lists will always be the same size. If there is no data, this method will succeed with empty ids and values.

remove

  • remove(id: V): Promise<any>
  • Remove a value using the data connector.

    Parameters

    • id: V

      The identifier for the data being removed.

    Returns Promise<any>

    A promise that is rejected if remove fails and succeeds otherwise.

    Notes

    This promise may resolve with a back-end response or undefined. Existence of resolved content in the promise is not prescribed and must be tested for. For example, some back-ends may return a copy of the item of type T being removed while others may return no content.

save

  • save(id: V, value: U): Promise<any>
  • Save a value using the data connector.

    Parameters

    • id: V

      The identifier for the data being saved.

    • value: U

      The data being saved.

    Returns Promise<any>

    A promise that is rejected if saving fails and succeeds otherwise.

    Notes

    This promise may resolve with a back-end response or undefined. Existence of resolved content in the promise is not prescribed and must be tested for. For example, some back-ends may return a copy of the item of type T being saved while others may return no content.

Generated using TypeDoc