KyselyK
Kysely2y ago
6 replies
yayza_

How do I compare to a value in a jsonb column?

I have this method:
    async getLatestLosingSpin(gameId: GameId) {
        const row: any = await this.db
            .selectFrom("slot_results.spin_results")
            .select("data")
            .where("game_id", "ilike", gameId)
            .where("data", "@>", JSON.stringify({ result: { game: { win: { total: "0.00" } } } }))
            .limit(1)
            .executeTakeFirst();

        return row;
    }

I'm pretty much trying to do the opposite. Where the "total" value isn't "0.00".
my table just has 3 columns "id", "game_id", and "data"
image.png
Was this page helpful?