diff --git a/README.md b/README.md index 93966ba..b0b9c32 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,8 @@ http://localhost:3000/cats?limit=5&page=2&sortBy=color:DESC&search=i&filter.age= ```ts import { Controller, Injectable, Get } from '@nestjs/common' import { InjectRepository } from '@nestjs/typeorm' -import { Repository, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' import { FilterOperator, Paginate, PaginateQuery, paginate, Paginated } from 'nestjs-paginate' +import { Repository, Entity, PrimaryGeneratedColumn, Column } from 'typeorm' @Entity() export class CatEntity { @@ -122,8 +122,8 @@ export class CatsService { public findAll(query: PaginateQuery): Promise> { return paginate(query, this.catsRepository, { - sortableColumns: ['id', 'name', 'color'], - searchableColumns: ['name', 'color'], + sortableColumns: ['id', 'name', 'color', 'age'], + searchableColumns: ['name', 'color', 'age'], defaultSortBy: [['id', 'DESC']], filterableColumns: { age: [FilterOperator.GTE, FilterOperator.LTE], @@ -154,6 +154,14 @@ const paginateConfig: PaginateConfig { */ sortableColumns: ['id', 'name', 'color'], + /** + * Required: false + * Type: [keyof CatEntity, 'ASC' | 'DESC'][] + * Default: [[sortableColumns[0], 'ASC]] + * Description: The order to display the sorted entities. + */ + defaultSortBy: [['name', 'DESC']], + /** * Required: false * Type: (keyof CatEntity)[] @@ -169,14 +177,6 @@ const paginateConfig: PaginateConfig { */ maxLimit: 20, - /** - * Required: false - * Type: [keyof CatEntity, 'ASC' | 'DESC'][] - * Default: [[sortableColumns[0], 'ASC]] - * Description: The order to display the sorted entities. - */ - defaultSortBy: [['name', 'DESC']], - /** * Required: false * Type: number @@ -194,9 +194,9 @@ const paginateConfig: PaginateConfig { /** * Required: false - * Type: FilterOperator - Based on TypeORM find operators + * Type: { [key in CatEntity]?: FilterOperator[] } - Operators based on TypeORM find operators * Default: None - * Find more at https://typeorm.io/#/find-options/advanced-options + * https://typeorm.io/#/find-options/advanced-options */ filterableColumns: { age: [FilterOperator.EQ, FilterOperator.IN] } }