JoinSpec
sourceDefines 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.
- inner constructs an inner equijoin.
- innerPredicate constructs an inner predicate join.
- left constructs an left outer equijoin.
- leftPredicate constructs a left outer predicate join.
Constructors
new JoinSpec(type: JoinType, leftHandField: string | number | symbol, query: Query, predicates: JoinPredicate[]): JoinSpecsource
Properties
leftHandField: 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.
predicates: JoinPredicate[]source
For a predicate join only, these are the comparators for the join.
For a predicate join only, this is the right-hand side of the join.
type: JoinTypesource
implements
JoinMetadata.type
The class of join.
Methods
Static methods
inner(field: string | number | symbol): JoinSpecsource
Defines an inner equijoin on a foreign key.
innerPredicate<T extends Model<string, T>>(query: Query, asName: string, predicates: JoinPredicate[]): JoinSpecsource
Defines an inner join on a set of predicates.
left(field: string | number | symbol): JoinSpecsource
Defines a left outer equijoin on a foreign key.
leftPredicate<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
applyFieldGuards<T>(target: AbstractCtor<T>, item: any, tracer: Tracer): Maybe<T>source
inherited from
ValidatableType.applyFieldGuards
validate<T extends ValidatableType<T>>(this: AbstractCtor<T> & CanHaveValidateHook<T>, item: any, tracer: Tracer = ...): Maybe<T>source
inherited from
ValidatableType.validate
withFields<T extends FieldDict>(fields: T): Validatable<MaterialisedType<T>> & Ctor<MaterialisedType<T>>source
inherited from
ValidatableType.withFields