Hey all, I'm trying to query a Postgres JSONB fiel...
# prisma-client
j
Hey all, I'm trying to query a Postgres JSONB field (and avoiding using raw) with the js client. Filtering by an array's object isn't supported w/ the Postgres connector yet - only MySQL as of right now. Performance isn't really a huge deal for me since the query is run once per day and isn't user-facing, but does anyone know if there's a (sane) way to use Prisma to return values from the JSONB column defined below where
name
is equal to
foo
? My current hack in raw SQL for when I don't feel like parsing and filtering like an adult is a shameful display of hubris with
items::TEXT ~ 'foo'
lol. Data shape in the "items" column:
Copy code
[
  {
    "name": "foo",
    "value": "example_1"
  },
  {
    "name": "bar",
    "value": "example_2"
  },
]
n
Hey James 👋 As of now, the raw query is the only straightforward solution till support for filtering in Postgres connector lands
j
@Nurul ah, that's totally fine - I just wanted to make sure I wasn't overcomplicating things needlessly. Thanks for the reply!
🙌 1