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

1.1K
Views
TypeORM querybuilder with take,skip and order by

I have an issue with a NestJs service that uses Typeorm and implements pagination logic.

When I use limit and offset on a query I execute using QueryBuilder, it does not return all results (i.e. limit 10 returns only 8 results)- it does work however, meaning that the relations aren't mapped yet still filtered on, orderby does order by a relation field without mapping it too. The issue began when I changed my limit and offset to take and skip.

It gets buggy when I use order by on a relation column I innerJoin.

For example:

querybuilder = querybuilder.innerJoin(profile.service, service)

then try to do

 queryBuilder = queryBuilder.orderBy("service.price", "ASC")

It returns an error

column distinctAlias.service_price does not exist

That's because it looks like you must leftJoinAndSelect the relation in order to have the field alias included in the query.

I don't want to select the relations but only the base entity. Is there any way around it?

Limit and offset as pagination utilities are not an option since in the docs itself it says to not use them when appending joins to the query.

over 4 years ago · Santiago Trujillo
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!