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 } },
          ],
        },
      }),


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:

  1. postgres:
https://kyse.link/?p=s&i=cI4gE4YRB4IWc6L90ulX

  1. mysql/sqlite:
https://kyse.link/?p=s&i=WoFXXNwErh94g2ehOScu
Was this page helpful?