I could not find any notion of OR operator neither in TypeORM docs nor in the source code. does it support it at all?
I'm trying to do perform a basic search with a repository.
db.getRepository(MyModel).find({
name : "john",
lastName: "doe"
})
I know this generates an AND operation but I need an OR operation so SQL would look like:
name='john' OR lastName='doe'
Am I forced to use the query builder for something basic like this?
Since version 0.3.18 (released 2024-01-03), TypeORM now supports an Or
operator in the basic .find* methods:
const users = await db.getRepository(User).findBy({
name: Or(Equal("John"), ILike("Jane%")),
})
-- Will generate the following query:
SELECT * FROM "user" WHERE "name" = 'John' OR "name" ILIKE 'Jane%'
Unfortunately this does not solve the scenario you presented, but just cases where only one field is involved. It might still be useful to other users though.