Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

42
Views
TypeORM AND Find Option

I have products with a price, I want to find products whose price will be less than 10 but more than 5. So that SQL query looks like this:

SELECT * FROM products WHERE products.price < 10 AND products.price > 5

Is it possible to do this without using Query Builder?

I don't find the And operator in the documentation

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You just need to use where operator.

userRepository.find({ where: { firstName: "Timber", lastName: "Saw" } });

This code executes this query:

SELECT * FROM "user" WHERE "firstName" = 'Timber' AND "lastName" = 'Saw'

And if you want to use OR, you use an array of conditions:

userRepository.find({
    where: [
        { firstName: "Timber", lastName: "Saw" },
        { firstName: "Stan", lastName: "Lee" },
    ],
});

This code will executes this query:

SELECT * FROM "user" WHERE ("firstName" = 'Timber' AND "lastName" = 'Saw') OR ("firstName" = 'Stan' AND "lastName" = 'Lee')

More infos in the doc: https://github.com/typeorm/typeorm/blob/master/docs/find-options.md

about 4 years ago · Juan Pablo Isaza Report

0

These docs clarify how to use find like SQL https://orkhan.gitbook.io/typeorm/docs/find-options

Note that for conditional where and other statements, you need QueryBuilder.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!