• Public
  • Public/Protected
  • All

Interface EntityRelationshipConfig<TSource, TData, TRawData, TId, TDataSet, T, TRawData, TInput>

Type parameters




Optional allItemsEndpoint

allItemsEndpoint: string

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.

Optional allItemsEndpointTrailingSlash

allItemsEndpointTrailingSlash: boolean

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.



Optional allItemsProperty

allItemsProperty: string

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.


Without allItemsProperty, the data returned from querying your API would have to be either an array or: { "items": [...] }

However, if we set allItemsProperty like this: { "allItemsProperty": "results" }

Then Paris will expect the data to be:

        "results: [...]


Optional allowedTypes

allowedTypes: Array<RelationshipType>

Optional baseUrl

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.

Optional cache

cache: boolean | DataCacheSettings<T>

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.

Optional customHeaders

customHeaders: function | Record<string, string>

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.



dataEntity: DataEntityType<TData>

Optional endpoint

The URL to use for HTTP requests.

Optional fixedData

fixedData: object

Query params to always send when requesting data.

Type declaration

  • [index: string]: any

Optional foreignKey

foreignKey: string

Optional getRelationshipData

getRelationshipData: function

Type declaration

    • (item?: TSource): object
    • Parameters

      • Optional item: TSource

      Returns object

      • [index: string]: any

Optional getRemoveData

getRemoveData: function

A function that returns data to send in the request body when DELETEing entities (by using repository.remove).


The entities that are removed.

Type declaration

    • (items: Array<TData>): any
    • Parameters

      • items: Array<TData>

      Returns any

Optional loadAll

loadAll: boolean

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.



Optional parseData

parseData: function

A function that if specifies, parses whatever is received from the API call, before Paris starts handling it.


Type declaration

Optional parseDataQuery

parseDataQuery: function

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.


Type declaration

Optional parseDataSet

parseDataSet: function

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.


Parsing a DataSet from a raw object returned by the backend

    parseDataSet: (rawDataSet:TodoRawDataSet) => ({ items: rawDataSet.todoItems, next: rawDataSet.$nextPage, count: rawDataSet.total })

Type declaration

    • (dataSet: TDataSet): DataSet<TRawData>
    • Parameters

      • dataSet: TDataSet

      Returns DataSet<TRawData>

Optional parseItemQuery

parseItemQuery: function

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.


Fetching an entity by specifying the ID in a query param rather than as a folder

parseItemQuery: itemId => `/todo?id=${itemId}`

Type declaration

Optional parseRemoveQuery

parseRemoveQuery: function

Similar to parseDataQuery, but for a remove call, rather than getItemById. Use it to specify the URL to use when removing entities.


Type declaration

Optional parseSaveQuery

parseSaveQuery: function

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.


Type declaration

Optional saveMethod

saveMethod: function | SaveRequestMethod

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 RequestMethods, 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.

Optional separateArrayParams

separateArrayParams: boolean

If true, a value that's specified in DataQuery.params and is an array will result in multiple params in the HTTP request


Using separateArrayParams

    singularName: 'My entity',
    pluralName: 'My entities',
    endpoint: 'myentity',
    separateArrayParams: true
export class MyEntity extends EntityModelBase{}

paris.query(MyEntity, { where: { foo: ['bar', 'lish'] }})
    .subscribe((dataSet:DataSet<MyEntity>) => console.log(dataSet));

In this example, the API call will be to (config.apiRoot)/myentity?foo=bar&foo=lish. If separateArrayParams wasn't specified as true, the api call would have been to: (config.apiRoot)/myentity?foo=bar,lish


sourceEntity: DataEntityType<TSource>

Optional timeout

timeout: number

If the HTTP request takes longer than this number (milliseconds), the request will fail with status 0.



Generated using TypeDoc