'Why skip() and take() not works when I use getRawMany() in nestJS with typeorm?

Here is the code I currently use.

with getRawMany() - skip and take not works!

const data = await getRepository(Enquiry)
  .createQueryBuilder('enq')
  .select([
    'enq.id AS id',
    'enq.location AS location',
    'enqStatus.name AS status'
  ])
  .leftJoin('enq.status', 'enqStatus')
  .skip(1)
  .take(3)
  .where(payload)
  .getRawMany()


Solution 1:[1]

Try with limit and offset

const data = await getRepository(Enquiry)
  .createQueryBuilder('enq')
  .select([
    'enq.id AS id',
    'enq.location AS location',
    'enqStatus.name AS status'
  ])
  .leftJoin('enq.status', 'enqStatus')
  .where(payload)
  .offset(meta.page)
  .limit(meta.pageSize)
  .getRawMany()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vignesh