KyselyK
Kysely3y ago
3 replies
bombillazo

Use JSON key as text

Hello, I am using the following syntax to fetch data in a JSONB column:
.select((eb) => [
  'id',
  eb
    .ref('jsonb_col', '->')
    .key('lvl_1')
    .key('value')
    .as('my_val'),
...

This returns
my_val
as a json value which is equivalent to using
->
, how can I retrieve the data using the Postgres
->>
operation that returns the data as TEXT?
Solution
aah, i had to change the first
->
to
->>
, doh!
Was this page helpful?