Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface RestRepositoryInterface<T>

The RestRepository retreives resources from the database through the REST API.

A full list of resources can be fetched by calling findAll and a specific resource by calling findOne.

Type parameters

  • T

Hierarchy

Index

Methods

create

  • create(): T
  • Factory method. Creates and returns a new empty instance of the entity.

    Returns T

filter

  • Find all repository items matching the filter parameters.

    Parameters

    Returns Promise<T[]>

findAll

  • findAll(forceFetch?: boolean): Promise<T[]>
  • Gets all repository items. The cached data will be returned if the data has been fetched before. Using the forceFetch parameter, a user can order a fresh copy to be fetched from the server.

    Parameters

    • Optional forceFetch: boolean

      Flag whether to force a server request or not. False by default.

    Returns Promise<T[]>

    Array of resources.

findOne

  • findOne(id: number, forceFetch?: boolean): Promise<T>
  • Gets one repository item by id. The cached data will be returned if the data has been fetched before. Using the forceFetch parameter, a user can order a fresh copy to be fetched from the server. In case a new record is fetched, the data will be updated accordingly.

    Parameters

    • id: number
    • Optional forceFetch: boolean

      False by default.

    Returns Promise<T>

remove

  • remove(item: T): Promise<void>
  • Deletes an item from the repository.

    Parameters

    • item: T

    Returns Promise<void>

save

  • save(resources: T | T[]): Promise<T[]>
  • Saves new and/or updated items.

    Parameters

    • resources: T | T[]

      The resource or array of resources to save or update.

    Returns Promise<T[]>

    A new array with referenced resources.

Generated using TypeDoc