本页还没有译文
本页 19 段还没译成Español,下面显示的是英文原文。MergeContextForJoinCallback
还没翻译译自英文(tanstack.com)本页 19 段都还没译
type MergeContextForJoinCallback<TContext, TNewSchema> = Omit<TContext, "schema" | "refsSchema" | "hasJoins" | "joinTypes"> & object;Defined in: packages/db/src/query/builder/types.ts:1328
MergeContextForJoinCallback - Special context for join condition callbacks
This type creates a context specifically for the onCallback parameter of join operations.
The key difference from MergeContextWithJoinType is that NO optionality is applied here.
Why No Optionality? In SQL, join conditions are evaluated BEFORE optionality is determined. Both tables must be treated as available (non-optional) within the join condition itself. Optionality is only applied to the result AFTER the join logic executes.
Example:
.from({ users })
.leftJoin({ orders }, ({ users, orders }) => {
// users is NOT optional here - we can access users.id directly
// orders is NOT optional here - we can access orders.userId directly
return eq(users.id, orders.userId)
})
.where(({ orders }) => {
// NOW orders is optional because it's after the LEFT JOIN
return orders?.status === 'pending'
})The simple intersection (&) merges schemas without any optionality transformation.
Type Declaration
baseSchema
baseSchema: TContext["baseSchema"];fromSourceName
fromSourceName: TContext["fromSourceName"];hasJoins
hasJoins: true;joinTypes
joinTypes: TContext["joinTypes"] extends Record<string, any> ? TContext["joinTypes"] : object & { [K in keyof TNewSchema & string]: "inner" };refsSchema
refsSchema: RefsSchemaForContext<TContext> & TNewSchema;schema
schema: TContext["schema"] & TNewSchema;Type Parameters
TContext
TContext extends Context
TNewSchema
TNewSchema extends ContextSchema
AI 翻译查看英文原文