function caseWhen<C1, V1>(condition1, value1): CaseWhenResult<[V1], false>;function caseWhen<C1, V1>(condition1, value1): CaseWhenResult<[V1], false>;Defined in: packages/db/src/query/builder/functions.ts:399
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;function caseWhen<C1, V1, D>(
condition1,
value1,
defaultValue): CaseWhenResult<[V1, D], true>;Defined in: packages/db/src/query/builder/functions.ts:403
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;function caseWhen<C1, V1, C2, V2>(
condition1,
value1,
condition2,
value2): CaseWhenResult<[V1, V2], false>;Defined in: packages/db/src/query/builder/functions.ts:408
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:419
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:432
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:447
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:464
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:483
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:504
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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>;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:527
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})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;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:552
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, 18), `adult`, `minor`)caseWhen(
gt(user.age, 65),
`senior`,
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)),
})caseWhen(gt(user.age, 18), {
...user,
posts: q
.from({ post: postsCollection })
.where(({ post }) => eq(post.userId, user.id)),
})