JoinSpec

source

Defines a join that forms part of a query specification.

Two primary kinds of join are supported: left outer joins, which return every record from the base model with optional matching records from the foreign model, and inner joins, which return only records where there is a match on both sides.

Both kinds of join are further broken down into two secondary classes: equijoins on foreign keys, which follow foreign relationships defined in the data model, and predicate joins, which are executed on arbitrary conditions.

Four shorthand methods are provided for composing join specifications.

Constructors

new JoinSpec(type: JoinType, leftHandField: string | number | symbol, query: Query, predicates: JoinPredicate[]): JoinSpecsource

Properties

readonlyleftHandField: string | number | symbolsource

implements JoinMetadata.leftHandField

For a foreign key equijoin, this is the foreign key field upon which to join. For a predicate join, this is the alias to assign to the join.

readonlypredicates: JoinPredicate[]source

For a predicate join only, these are the comparators for the join.

readonlyquery: Querysource

For a predicate join only, this is the right-hand side of the join.

readonlytype: JoinTypesource

implements JoinMetadata.type

The class of join.

Methods

Static methods

staticinner(field: string | number | symbol): JoinSpecsource

Defines an inner equijoin on a foreign key.

staticinnerPredicate<T extends Model<string, T>>(query: Query, asName: string, predicates: JoinPredicate[]): JoinSpecsource

Defines an inner join on a set of predicates.

staticleft(field: string | number | symbol): JoinSpecsource

Defines a left outer equijoin on a foreign key.

staticleftPredicate<T extends Model<string, T>>(query: Query, asName: string, predicates: JoinPredicate[]): JoinSpecsource

Defines a left outer join on a set of predicates.

Instance methods

serialise(metadata: ModelReflectionMetadata): anysource

Inherited methods

staticapplyFieldGuards<T>(target: AbstractCtor<T>, item: any, tracer: Tracer): Maybe<T>source

inherited from ValidatableType.applyFieldGuards

staticvalidate<T extends ValidatableType<T>>(this: AbstractCtor<T> & CanHaveValidateHook<T>, item: any, tracer: Tracer = ...): Maybe<T>source

inherited from ValidatableType.validate

staticwithFields<T extends FieldDict>(fields: T): Validatable<MaterialisedType<T>> & Ctor<MaterialisedType<T>>source

inherited from ValidatableType.withFields