RecordProxy

source

Proxies a composite record (a base record plus a set of left-joined fields) and resolves accesses to foreign fields by performing a memoised join.

For best performance, avoid using the proxy if no joins are required. Instead, prefer using the base record directly.

Constructors

new RecordProxy<T extends Model<string, T>>(provider: RecordProxyProvider, sourceRecord: T): RecordProxysource

Properties

readonlyhandler: ProxyHandler<RecordProxy<T>>source

readonlyprovider: RecordProxyProvidersource

resolvedJoins: Map<string | number | symbol, Model<string>>source

Caches the foreign record for each join. Field accesses are resolved from this cache; if there is no entry in the cache for a join, that join is executed and the cache is populated with the result.

readonlysourceRecord: Tsource

Methods

Instance methods

[custom](): anysource

getProxy(): Tsource

invalidate(): voidsource

Clear the join cache. Each join will be reevaluated the next time a field of that join is accessed via the proxy.

isInvalidatedBy(incomingRhs: Model<string>): booleansource

Returns true if the foreign record invalidates this joined record. This is the case when the left-hand side of any join resolves to the incoming foreign record, or the left-hand side of any join previously resolved to the incoming foreign record but no longer does.

resolve(field: string | number | symbol): anysource

Resolves property accesses via this proxy to the correct value. The magic field _proxy can be used to access this proxy object itself.