Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OneToManyRelationship<K, V, T>

Cache map for tracking model foreign key relationships so that we have rapid lookup speed for associated models.

example
// Has many orders
interface Product {
        id: number; // is the primary key
}

// Has exactly one product
interface ProductOrder {
        id: number;
        productId: number; // is the foreign key
}

Type parameters

  • K

  • V

  • T

Hierarchy

  • OneToManyRelationship

Index

Constructors

constructor

Properties

Readonly changes

changes: Observable<EntityPropertyChangeEvent<K, T>> = ...

Changes for foriegn entity relations usually happen on the foreign entity itself, rather than the primary entity.

For example: ProductOrder has 'id' and 'productId' - a Product can have many orders associated with it, but the value being changed is 'productId' on ProductOrder, not 'id' on Product.

Protected Readonly entityMap

entityMap: RxEntityMap<K, V, RxMap<K, V, Map<K, V>>>

Protected Readonly selectForeignKey

selectForeignKey: PropertySelector<T, V>

Protected Readonly store

store: Map<T, OneToManyContext<T, K>> = ...

Methods

associate

  • associate(id: T, fk: K): void

clear

  • clear(): void

consume

deletePrimaryKeyContext

  • deletePrimaryKeyContext(id: T): boolean

disassociate

  • disassociate(id: T, fk: K): void

getPrimaryKeyContext

getPrimaryKeys

  • getPrimaryKeys(): T[]

getRelatedKeyCount

  • getRelatedKeyCount(id: T): number

getRelatedKeys

  • getRelatedKeys(id: T): K[]

getRelatedValues

  • getRelatedValues(id: T): V[]

hasAnyAssociation

  • hasAnyAssociation(id: T): boolean

hasAssociation

  • hasAssociation(id: T, fk: K): boolean

watchPrimaryKey

  • watchPrimaryKey(id: T): Observable<V[]>

Generated using TypeDoc