JSON Object Traversal
Hi everyone, new user of Kysely.
I have the following json object inside a
sess
column:
I'm trying to write a type-safe Kysely query to traverse this. Essentially, I want a Postgresql query that looks like this:
I'm almost there, however, I'm running into some issue getting thjat last ->>
part. Here is what I have so far:
this, unfortunately, generates a query like this:
(notice that the last user -> user_id
is not a ->>
, as it should be) which causes postgresql to fail.
How am I supposed to tell Kysely to use ->>
on the last step there?3 Replies
I saw that there is a
jsonPath
function which I played around for a bit, but I wasn't able to tell jsonPath
to use my sess
column which caused it to fail.Solution
Just use
->>
for all of them?:o, I have no idea why I didn't think that would work
I was thinking postgresql would treat the
passport
object as a text rather than continue to follow it as json
thanks 😄