RecordProxyProvider
sourceManages the metadata required for constructing RecordProxy objects.
A view that has joins will have one RecordProxyProvider instance that deals RecordProxy instances for each row of the view. This allows for metadata and state about the joins to be shared at the view level rather than being recreated for each individual row.
Constructors
new RecordProxyProvider<T extends Model<string, T>>(context: Context, query: Query, metadata: QueryReflectionMetadata): RecordProxyProvidersource
Properties
joinExecutors: Map<string | number | symbol, JoinExecutor<T, Model<any>>>source
Each join has an 'executor' which resolves a LHS record to a RHS record by applying the conditions of the join.
joinExecutorsByModel: SetMap<ModelType<Model<string>>, JoinExecutor<T, Model<any>>>source
The same as joinExecutors, but grouped by foreign model.
keys: string[]source
Cached field names, used for the proxy's ownKeys handler.
metadata: QueryReflectionMetadatasource
resolvers: Map<string | number | symbol, Function>source
Each field of the composite record has a 'resolver', which is a function that takes a single record proxy argument and applies the logic needed to look up the value either directly on the base record or via a foreign join.
Methods
Instance methods
dispose(): voidsource
When the parent view is disposed, we need to release any materialised subquery views so that they can be disposed of as well.
getTransform(): Functionsource
Returns a function that receives a base record and returns a Proxy that wraps that record with the interceptors that execute the joins.
makeEquijoinExecutor(context: Context, join: JoinSpec): voidsource
Builds the executor for an equijoin. This is a PK lookup against the root view for the foreign model in this context.
makeJoinExecutors(context: Context): voidsource
Builds the executors for each join.
makeJoinResolvers(): voidsource
Builds the resolvers for each join.
makeSubqueryJoinExecutor<Right extends Model<string, Right>>(context: Context, leftHandField: string | number | symbol, query: Query, predicates: JoinPredicate[]): voidsource
Builds the executor for a subquery join. This is a scan of a view for the subquery.
makeSubqueryNonPkJoinExecutor<Right extends Model<string, Right>>(subqueryView: Handle, predicates: JoinPredicate[]): JoinExecutor<T, Model<string>>source
Slow path: for the general join case, use a table scan to get the RHS record.
makeSubqueryPkJoinExecutorMaybe<Right extends Model<string, Right>>(subqueryView: Handle, predicates: JoinPredicate[]): undefined | JoinExecutor<T, Model<string>>source
Fast path: if the join clause consists of a single "eq" predicate where the field of the RHS is its primary key, use a hashtable lookup to get the RHS record.