followRef

Function: followRef()

ts
function followRef(
   query, 
   ref, 
   collection): 
  | void
  | {
  alias?: string;
  collection: Collection;
  path: string[];
};
function followRef(
   query, 
   ref, 
   collection): 
  | void
  | {
  alias?: string;
  collection: Collection;
  path: string[];
};

Defined in: packages/db/src/query/ir.ts:332

Follows the given reference in a query until its finds the root field the reference points to.

Parameters

query

QueryIR

ref

PropRef<any>

collection

Collection

Returns

| void | { alias?: string; collection: Collection; path: string[]; }

The collection, its alias, and the path to the root field in this collection. alias is the alias under which the resolved collection is referenced in the query it was reached from (when the ref crosses into a joined source). It is left undefined when the ref simply resolves to a field on the passed-in collection, in which case the caller already knows the alias.