title: How to implement pagination in NestJS with TypeORM
body: <p>Is there any way to get the total count and records with a single query, instead of running it as 2 separate queries?</p>
  <p>If it's not possible, is there any way to reuse the where condition in both queries?</p>
  <pre class="lang-ts prettyprint-override"><code>async findAll(query): Promise&lt;Paginate&gt; {
    const take = query.take || 10
    const skip = query.skip || 0
    const keyword = query.keyword || ''
  
    const builder = this.userRepository.createQueryBuilder(&quot;user&quot;)
    const total = await builder.where(&quot;user.name like :name&quot;, { name: '%' + keyword + '%' }).getCount()
    const data = await builder.where(&quot;user.name like :name&quot;, { name: '%' + keyword + '%' }).orderBy('name', 'DESC').skip(skip).take(take).getMany();
  
    return {
      data: data,
      count: total
    }
  }
  
  {
    count: 10,
    data: [
      {
        id: 1,
        name: 'David'
      },
      {
        id: 2,
        name: 'Alex'
      }]
  }
  </code></pre>