Normally, Paris follows the REST standard, and tries to fetch data for an Entity from the given endpoint + '/'. i.e:
If endpoint === 'todo', querying the Entity would result in an HTTP GET from /api/todo/
However, if allItemsEndpointTrailingSlash is set to false
, the trailing slash is removed and the HTTP GET would be from /api/todo.
When fetching multiple items, Paris expects in the response either an array or an object with an 'items' property, that has an array value. allItemsProperty can be specified for changing the default 'items' property to whatever your response contains.
The domain to use for all calls for this Entity/ApiCall. Used as a prefix for all HTTP requests. Set to an empty string to avoid this altogether (in case the data arrives from an external URL, for example). If not set and not an empty string, Paris will use config.apiRoot instead.
If cache
is specified, entities will be cached according to the cache settings.
Note: cache refers to individual items (such as received from getItemById
or with an ApiCall), not queries.
Custom headers for API call. It can be either a dictionary of string, with header names as the keys, or a function (which be applied by Paris) which receives data and config, and returns the headers for the API call.
The URL to use for HTTP requests.
Query params to always send when requesting data.
A function that returns data to send in the request body when DELETE
ing entities (by using repository.remove).
If true, all the Entity's items are fetched whenever any is needed, and then cached so subsequent requests are retrieved from cache rather than backend. This makes sense to use for Entities whose values are few and not expected to change, such as enums.
A function that if specifies, parses whatever is received from the API call, before Paris starts handling it.
When a query
is performed, a DataQuery
object can be specified with options for the query.
parseDataQuery
receives that DataQuery object and allows to modify it, so Paris can send to the API what it expects.
For query results, Paris accepts either an array of items or an object. That object may contain properties such as 'count', 'next' and 'previous'.
parseDataSet
, if available, receives the object as it was returned from the API and parses it to a DataSet interface, so the original properties are available in the DataSet.
When getting an Entity from backend (when calling repository.getItemById), Paris follows the REST standard and fetches it by GET from /{the Entity's endpoint}/{ID}.
parseItemQuery
allows to specify a different URL. This is useful if your API doesn't follow the REST standard.
Similar to parseDataQuery
, but for a remove
call, rather than getItemById
. Use it to specify the URL to use when removing entities.
Similar to parseDataQuery
, but for a save
call, rather than getItemById
. Use it to specify the URL to use when creating or updating an Entity.
Set the saveMethod of an Entity to determine the HTTP method to use in the request to the backend when saving an entity.
Since this can be either a function or one of the RequestMethod
s, the method can be either hardcoded for all save
calls of this Entity, or determined at runtime for each call.
For example, you might want to use POST instead of Paris' default PUT when updating an existing entity, or you might want to use PATCH instead.
If true
, a value that's specified in DataQuery.params and is an array will result in multiple params in the HTTP request
If the HTTP request takes longer than this number (milliseconds), the request will fail with status 0.
Generated using TypeDoc
Normally, Paris follows the REST standard, and tries to fetch data for an Entity from the given endpoint + '/'. i.e: If endpoint === 'todo', querying the Entity would result in an HTTP GET from /api/todo/ However, if allItemsEndpoint is set to 'all', the HTTP GET would be from /api/todo/all.