简体   繁体   中英

TypeORM SELECT with IN on view from jsonb

I have 2 tables. I do left join on them and in select I do company.data -> 'number' as company_number, . Then when I want to query those data.

this.find({ where: { company_number: In(1,2,3) } });

But instead of result I have error. QueryFailedError: operator does not exist: json = json,

Any idea how can I solve this problem?

What I had to do was adding type conversion in postgres query. So company.data -> 'number' as company_number . Is now (company.data -> 'number')::text as company_number .

And it works almost well, but it add quotation marks around original value. So A becomes "A" .

To fix this I used:

(company.data -> 'number')#>>'{}' as company_number,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM