Search code examples
sqltypescriptpostgresqltypeorm

How can I write a SQL query in typeorm in the form `SELECT * FROM t WHERE (Z AND (X OR Y))`


I want to write a SQL query in TypeORM, something like this:

SELECT * 
FROM table 
WHERE (Z AND (X OR Y))

I try something like

[ {Z: true, 0: [{X : true, Y: true }] } ]

but it doesn't work because there's no column '0' in the database.

How can I write a SQL query in TypeORM like that?


Solution

  • This other question on stackoverflow might answer your question: other question. It's 1yo so I can't say whether there have been any modifications with regards to this matter. Sincerely I haven't tried TypeORM yet. But as of the time of that answer you could either repeat parameters or user the query builder with brackets.

    Hope it helps. I know how horrible it is to be stuck on the limitations of an ORM, Sequelize was and still is a real pain for me.