Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RelationshipRepository<TSource, TData, TRawData>

A Repository is a service through which all of an Entity's data is fetched, cached and saved back to the backend.

Relationship repository handles two repositories that are defined using a foreign key

Type parameters

Hierarchy

Implements

Index

Constructors

constructor

Properties

allowedTypes

allowedTypes: Set<RelationshipType>

dataEntityType

dataEntityType: DataEntityType<TData>

entityConstructor

entityConstructor: DataEntityType<TData, TRawData>

error$

error$: Observable<EntityErrorEvent>

relationshipConfig

relationshipConfig: EntityRelationshipConfig<TSource, TData>

sourceEntityType

sourceEntityType: DataEntityType<TSource>

sourceItem

sourceItem: TSource

Accessors

allItems$

  • get allItems$(): Observable<Array<TData>>
  • 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.

    Returns Observable<Array<TData>>

entity

modelConfig

values

  • get values(): Array<TData>

Methods

addCustomHeaders

  • addCustomHeaders(data: any): Record<string, string>

clearAllValues

  • clearAllValues(): void

clearCache

  • clearCache(): void

createItem

  • 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.

    Parameters

    • rawData: TRawData

      The raw data for the entity, as it arrives from backend

    • Default value options: DataOptions = { allowCache: true, availability: DataAvailability.available }
    • Optional query: DataQuery

    Returns Observable<TData>

createNewItem

  • createNewItem(): TData

getEndpointName

getEndpointUrl

getItemById

getQueryHttpOptions

getRelatedItem

getRelatedItemById

query

queryForItem

queryForItemId

  • Queries the relationship for an item ID instead of sourceItem or entity/valueObject. Note: there has to be a foreignKey set in the RelationshipRepository config, otherwise this will not work.

    Parameters

    Returns Observable<DataSet<TData>>

queryItem

serializeItem

  • serializeItem(item: Partial<TData>, serializationData?: any): TRawData

Static validateItem

  • validateItem<TEntity, TRawData>(item: __type, entity: ModelConfig<TEntity, TRawData>): boolean

Generated using TypeDoc