为什么当我在 NestJS 中使用 typeorm 使用 getRawMany() 时,skip() 和 take() 不起作用?

Vig*_*esh 7 typeorm nestjs

这是我当前使用的代码。

使用 getRawMany() - 跳过并采取不起作用!

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()
Run Code Online (Sandbox Code Playgroud)

小智 12

尝试使用限制和偏移

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()
Run Code Online (Sandbox Code Playgroud)