An Observable for all the items of this entity. If the Entity has already loaded all possible items (if loadAll
is set to true
, for example), those items are returned.
Otherwise, a query with no DataQuery will be performed to the backend and the data will be fetched.
All the hard-coded values of an Entity, as specified through the values
configuration.
Clears the cached values in the Repository, if they were set as a result of using allItems$ or loadAll: true
.
Clears all cached data in this Repository
Creates a full model of this Repository's Entity. Any sub-models that need to be fetched from backend will be fetched (if options.availability === DataAvailability.deep). This method is used internally when modeling entities and value objects, but may be used externally as well, in case an item should be created programmatically from raw data.
The raw data for the entity, as it arrives from backend
Creates a new instance of the Repository's entity. All fields will be undefined, except those that have defaultValue or those that are arrays, which will have an empty array as value.
Returns the base URL for this Repository's API calls (not including base URL - the domain)
Returns the full URL for an API call
Fetches an item from backend, for the specified ID, or from cache, if it's available.
Returns the HttpOptions for the specified DataQuery.
Uses the entity config's parseDataQuery
configuration, if available, or otherwise the queryToHttpOptions
function.
If the entity config has fixedData
set, the fixed data will be added to the HttpOptions params.
Gets multiple items from backend. The backend may add paging information, such as count, page, etc, so a DataSet object is returned rather than just an Array.
Same as {@link ReadonlyRepository#query|query}, but returns a single item rather than a {DataSet}. Useful for when we require to fetch a single model from backend, but it's either a ValueObject (so we can't refer to it by ID) or it's fetched by a more complex data query.
Sends a DELETE request to the backend for deleting multiple entities.
Sends a DELETE request to the backend for deleting an item.
Saves an entity to the server
Any data to pass to serialize or serializeItem
Saves multiple items to the server, all at once
Creates a JSON object that can be saved to server, with the reverse logic of getItemModelData
Validates that the specified item is valid, according to the requirements of the entity (or value object) it belongs to. Meaning, that it can be used as data for creating an instance of T.
Generated using TypeDoc
A Repository is a service through which all of an Entity's data is fetched, cached and saved back to the backend.
This class handles entities that can be added, updated or removed. see
ReadonlyRepository
base class.