Precondition: I'm using Typeorm to perform database queries and I can't use the queryBuilder methods to create this query, but only the find method.
I need to translate a query like:
SELECT * FROM address where zip = 123 and (street = 'asd' or city = 'New York');
I know that the solution can be trivial using the usual queryBuilder, but in this particular case I cannot use it.
Is it possible to implement these nested and/or conditions only using the find method?
Can you please try this?
Address.find([{
zip: 123, street: 'asd'
}, {
zip: 123, city: 'New York'
}]);
if you have just and, or conditions, yes! it's possible to implement the query only with find method.
In typeorm query, you can represent or with the array of the conditions.
zip = 123 and (street = 'asd' or city = 'New York')
is same as
(zip = 123 and street = 'asd') or (zip = 123 and city = 'New York')
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