Skip to content

HalStorage

Mihael Safaric edited this page Mar 25, 2020 · 2 revisions

When fetching a model via findOne method, fetched models will be automatically saved in memory.

When fetching a list of models via find method, fetched models will be automatically saved in memory only:

  • if model with the same unique identifier** does not exist** in the store
  • or, if savePartialModel is set to true

The reason behind this decision:

Embedded Resources may be a full, partial, or inconsistent version of the representation served from the target URI.

HAL specification

The storage is used to find a relationship of a model.

Example

class User extends HalModel {
  @HasOne()
  car: Car;
}

When accessing user.car, the library checks the storage and if the resource car is found, that resource is returned, otherwise, undefined is returned.