0.1.1 • Published 2 years ago

@drzioner/nestjs-paginate v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

NestJS Paginate

Library for NestJS and TypeORM paging in a simple way

Installation

npm i @drzioner/nest-paginate
# or
yarn add @drzioner/nest-paginate

Usage

Example

import {
  paginate,
  PaginateDto,
  QueryPaginateDto,
} from '@drzioner/nestjs-paginate';

async function findAndPaginate(query: QueryPaginateDto): Promise<PaginateDto> {
    return paginate(
      {
        type: User,
        dto: UserDto,
        fields: ['name', 'lastname', 'username', 'email'],
        relations: ['roles'],
        route: 'users',
      },
      query,
      { status: 'ASC', name: 'ASC' },
    );
}
  
const paginate = await findAndPaginate({});
console.log('paginate', paginate);

# paginate [
#   {
#     name: 'user',
#     lastname: 'admin',
#     ...
#   }
# ]