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?
db.getRepository(MyModel).find({ where: [ { name: "john" }, { lastName: "doe" } ] })
Pass an array to where
I had the same issue, but I worked around it with the QueryBuilder.
This would be an example.
return await getRepository(MyModel) .createQueryBuilder() .where("name = :name OR lastName = :lastName", { name: "john", lastName: "doe" }) .getMany();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With