import Dream from '../Dream.js'; import { PassthroughOnClause } from '../types/associations/shared.js'; import { PassthroughColumnNames } from '../types/dream.js'; import { VariadicLeftJoinLoadArgs } from '../types/variadic.js'; import DreamTransaction from './DreamTransaction.js'; export default class LeftJoinLoadBuilder { private dreamTransaction?; private dream; private query; /** * An intermediate builder for loading associations onto a Dream model * via a single left-join SQL query. Accessed via `#leftJoinLoad`. * * **Note:** The LeftJoinLoadBuilder works on a clone of the original model. * Call `.execute()` to get the clone with associations loaded. * * ```ts * const user = await User.firstOrFail() * const loaded = await user.leftJoinLoad('settings').execute() * loaded.settings // association is loaded on the returned clone * ``` */ constructor(dream: Dream, dreamTransaction?: (DreamTransaction | null) | undefined); passthrough, PassthroughColumns extends PassthroughColumnNames>(this: I, passthroughWhereStatement: PassthroughOnClause): I; /** * Attaches a leftJoinLoad statement to the load builder * * ```ts * const user = await User.firstOrFail() * await user * .leftJoinLoad('settings') * .leftJoinLoad('posts', 'comments', 'replies', ['image', 'localizedText']) * .execute() * ``` */ leftJoinLoad, DB extends DreamInstance['DB'], TableName extends DreamInstance['table'], Schema extends DreamInstance['schema'], const Arr extends readonly unknown[], const LastArg extends VariadicLeftJoinLoadArgs>(this: I, ...args: [...Arr, LastArg]): I; /** * Executes the left-join load query, returning a **clone** of the original model * with all requested associations loaded. The original instance is not modified. * * ```ts * const user = await User.firstOrFail() * const loaded = await user * .leftJoinLoad('settings') * .leftJoinLoad('posts', 'comments', 'replies') * .execute() * * loaded.settings // works — associations are on the returned clone * ``` * * @returns A clone of the Dream instance with all requested associations loaded */ execute(): Promise; private associationToPreloadedDreamsAndWhatTheyPointTo; private leftJoinLoadedAssociationValue; }