How to do a WHERE clause for a JSON field in kysely

Basically the title. I'm trying to convert the following prisma query to kysely and can't figure out how to do the individual statements inside the where:
prisma.tournament.findMany({
take: 24,
where: {
AND: [
{ data: { path: ["privacy"], equals: "public" } },
{ data: { path: ["deleteTime"], equals: Prisma.JsonNull } },
{ data: { path: ["endTime"], equals: Prisma.JsonNull } },
],
},
}),
prisma.tournament.findMany({
take: 24,
where: {
AND: [
{ data: { path: ["privacy"], equals: "public" } },
{ data: { path: ["deleteTime"], equals: Prisma.JsonNull } },
{ data: { path: ["endTime"], equals: Prisma.JsonNull } },
],
},
}),
data is a Jsonb column. Anybody know how to do this?
Solution:
Hey šŸ‘‹ A built-in type-safe support for json traversal might be introduced in a future release. There's a PR I'm experimenting in. Postgres as always is different šŸ˜ . For now:...
Jump to solution
2 Replies
Solution
Igal
Igalā€¢14mo ago
Hey šŸ‘‹ A built-in type-safe support for json traversal might be introduced in a future release. There's a PR I'm experimenting in. Postgres as always is different šŸ˜ . For now: 1. postgres: https://kyse.link/?p=s&i=cI4gE4YRB4IWc6L90ulX 2. mysql/sqlite: https://kyse.link/?p=s&i=WoFXXNwErh94g2ehOScu
Tom
Tomā€¢14mo ago
Awesome. Thanks