function caseWhen<C1, V1>(condition1, value1): CaseWhenResult<[V1], false>;Defined in: packages/db/src/query/builder/functions.ts:405
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C1
V1
CaseWhenResult<[V1], false>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, D>(
condition1,
value1,
defaultValue): CaseWhenResult<[V1, D], true>;Defined in: packages/db/src/query/builder/functions.ts:409
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
D extends CaseWhenValue
C1
V1
D
CaseWhenResult<[V1, D], true>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2>(
condition1,
value1,
condition2,
value2): CaseWhenResult<[V1, V2], false>;Defined in: packages/db/src/query/builder/functions.ts:414
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C1
V1
C2
V2
CaseWhenResult<[V1, V2], false>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, D>(
condition1,
value1,
condition2,
value2,
defaultValue): CaseWhenResult<[V1, V2, D], true>;Defined in: packages/db/src/query/builder/functions.ts:425
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
D extends CaseWhenValue
C1
V1
C2
V2
D
CaseWhenResult<[V1, V2, D], true>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3>(
condition1,
value1,
condition2,
value2,
condition3,
value3): CaseWhenResult<[V1, V2, V3], false>;Defined in: packages/db/src/query/builder/functions.ts:438
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C1
V1
C2
V2
C3
V3
CaseWhenResult<[V1, V2, V3], false>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, D>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
defaultValue): CaseWhenResult<[V1, V2, V3, D], true>;Defined in: packages/db/src/query/builder/functions.ts:453
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
D extends CaseWhenValue
C1
V1
C2
V2
C3
V3
D
CaseWhenResult<[V1, V2, V3, D], true>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, C4, V4>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
condition4,
value4): CaseWhenResult<[V1, V2, V3, V4], false>;Defined in: packages/db/src/query/builder/functions.ts:470
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C4 extends ExpressionLike
V4 extends CaseWhenValue
C1
V1
C2
V2
C3
V3
C4
V4
CaseWhenResult<[V1, V2, V3, V4], false>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, C4, V4, D>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
condition4,
value4,
defaultValue): CaseWhenResult<[V1, V2, V3, V4, D], true>;Defined in: packages/db/src/query/builder/functions.ts:489
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C4 extends ExpressionLike
V4 extends CaseWhenValue
D extends CaseWhenValue
C1
V1
C2
V2
C3
V3
C4
V4
D
CaseWhenResult<[V1, V2, V3, V4, D], true>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, C4, V4, C5, V5>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
condition4,
value4,
condition5,
value5): CaseWhenResult<[V1, V2, V3, V4, V5], false>;Defined in: packages/db/src/query/builder/functions.ts:510
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C4 extends ExpressionLike
V4 extends CaseWhenValue
C5 extends ExpressionLike
V5 extends CaseWhenValue
C1
V1
C2
V2
C3
V3
C4
V4
C5
V5
CaseWhenResult<[V1, V2, V3, V4, V5], false>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, C4, V4, C5, V5, D>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
condition4,
value4,
condition5,
value5,
defaultValue): CaseWhenResult<[V1, V2, V3, V4, V5, D], true>;Defined in: packages/db/src/query/builder/functions.ts:533
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C4 extends ExpressionLike
V4 extends CaseWhenValue
C5 extends ExpressionLike
V5 extends CaseWhenValue
D extends CaseWhenValue
C1
V1
C2
V2
C3
V3
C4
V4
C5
V5
D
CaseWhenResult<[V1, V2, V3, V4, V5, D], true>
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})function caseWhen<C1, V1, C2, V2, C3, V3, C4, V4, C5, V5>(
condition1,
value1,
condition2,
value2,
condition3,
value3,
condition4,
value4,
condition5,
value5,
condition6,
value6, ...
rest): any;Defined in: packages/db/src/query/builder/functions.ts:558
Returns the value for the first matching condition, similar to SQL CASE WHEN.
Arguments are evaluated as condition/value pairs followed by an optional default value. Scalar branch values return a query expression and can be used in expression contexts like select, where, orderBy, groupBy, having, and equality join operands. If no scalar branch matches and no default is provided, the result is null.
When a branch value is a projection object, caseWhen becomes a select-only projection value. Projection branches can include nested fields, ref spreads, and includes. If no projection branch matches and no default is provided, the result is undefined.
C1 extends ExpressionLike
V1 extends CaseWhenValue
C2 extends ExpressionLike
V2 extends CaseWhenValue
C3 extends ExpressionLike
V3 extends CaseWhenValue
C4 extends ExpressionLike
V4 extends CaseWhenValue
C5 extends ExpressionLike
V5 extends CaseWhenValue
C1
V1
C2
V2
C3
V3
C4
V4
C5
V5
ExpressionLike
CaseWhenValue
...CaseWhenValue[]
any
caseWhen(gt(user.age, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
gt(user.age, 18),
`adult`,
`minor`,
)caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})