How to left join JSON function in TypeORM

Viewed 321

Is there anyway to left join JSON function in TypeORM ? I'm trying to do something like below:

 .leftJoin(`json_array_elements ((v1.profile -> 'associatedProfiles') :: json)`, 'ap', 'true')

But this results in query something like:

 LEFT JOIN "json_array_elements  ((v1"."profile -> 'associatedProfiles') :: json)" "ap" ON true

and fails with an error:

 error: relation "json_array_elements  ((v1.profile -> 'associatedProfiles') :: json)" does not exist

It seems TypeORM seems to be strinfifying my left join. Instead what I really need there is

 LEFT JOIN  json_array_elements  ((v1.profile -> 'associatedProfiles') :: json) ap ON true

Any pointers to how to fix/overcome this? Thanks for your help.

1 Answers

you can do it using

.leftJoinAndMapMany()

or

leftJoinAndMapOne()

Related