K
Kysely6mo ago
sirhype

case() return boolean (castTo doesn't work?)

Hiya! I'm trying to determine if what I'm doing is currently possible I have the following expression
const result = await db
.selectFrom("zamdle_submissions")
.selectAll()
.leftJoin(
"zamdle_clips",
"zamdle_clips.twitch_id",
"zamdle_submissions.twitch_id"
)
.select((eb) =>
eb
.case()
.when("zamdle_clips.twitch_id", "is not", null)
.then(true)
.else(false)
.end()
.as("has_matching_clip")
)
.execute();
const result = await db
.selectFrom("zamdle_submissions")
.selectAll()
.leftJoin(
"zamdle_clips",
"zamdle_clips.twitch_id",
"zamdle_submissions.twitch_id"
)
.select((eb) =>
eb
.case()
.when("zamdle_clips.twitch_id", "is not", null)
.then(true)
.else(false)
.end()
.as("has_matching_clip")
)
.execute();
Currently this will return:
"has_matching_clip": "1"
"has_matching_clip": "1"
which I can work with, however I'm trying to have it return as true/false, or at the very least a number. I've tried using castTo after .end() but it doesn't seem to work. Any advice?
0 Replies
No replies yetBe the first to reply to this messageJoin