K
Kysely•2y ago
kewp

Property does not exist on type

Hello. I'm trying to run the following query:
result = await db.selectFrom("data")
.select(['partner_cd','reporter_cd'])
.where(({ cmpr, or, and, not, exists, selectFrom, val }) => or([
and([
cmpr('reporter_cd', '=', country),
cmpr('country_cd', '=', partner)
]),
and([
cmpr('country_cd', '=', country),
cmpr('reporter_cd', '=', partner)
]),
]))
.execute();
result = await db.selectFrom("data")
.select(['partner_cd','reporter_cd'])
.where(({ cmpr, or, and, not, exists, selectFrom, val }) => or([
and([
cmpr('reporter_cd', '=', country),
cmpr('country_cd', '=', partner)
]),
and([
cmpr('country_cd', '=', country),
cmpr('reporter_cd', '=', partner)
]),
]))
.execute();
but I'm getting the following error:
Property 'cmpr' does not exist on type 'WhereInterface<From<DB, "data">, "data">'
Property 'cmpr' does not exist on type 'WhereInterface<From<DB, "data">, "data">'
Any help appreciated.
Solution:
Hey 👋 What kysely version are you using? cmpr (and other cool new expression builder stuff) is only available from 0.24.x...
Jump to solution
7 Replies
Solution
Igal (mobile)
Igal (mobile)•2y ago
Hey 👋 What kysely version are you using? cmpr (and other cool new expression builder stuff) is only available from 0.24.x
kewp
kewpOP•2y ago
Hello Yes it's verion 0.23
Igal (mobile)
Igal (mobile)•2y ago
You need to upgrade to latest
kewp
kewpOP•2y ago
Ok will do
kewp
kewpOP•2y ago
BTW how could I implement this expression without this new expression builder stuff ?
Igal
Igal•2y ago
kysely
.selectFrom("data")
.where((wb) =>
wb.where("reporter_cd", "=", country).where("country_cd", "=", partner),
)
.orWhere((wb) =>
wb.where("country_cd", "=", country).where("reporter_cd", "=", partner),
)
.select(["partner_cd", "reporter_cd"])
.execute()
kysely
.selectFrom("data")
.where((wb) =>
wb.where("reporter_cd", "=", country).where("country_cd", "=", partner),
)
.orWhere((wb) =>
wb.where("country_cd", "=", country).where("reporter_cd", "=", partner),
)
.select(["partner_cd", "reporter_cd"])
.execute()
https://kyse.link/?p=s&i=y4MGy7uooZhq3NKtW7o9
kewp
kewpOP•2y ago
Thanks so much That works great
Want results from more Discord servers?
Add your server