fix: update readme
This commit is contained in:
parent
6876ebca85
commit
750d7850b9
26
README.md
26
README.md
@ -95,8 +95,8 @@ http://localhost:3000/cats?limit=5&page=2&sortBy=color:DESC&search=i&filter.age=
|
|||||||
```ts
|
```ts
|
||||||
import { Controller, Injectable, Get } from '@nestjs/common'
|
import { Controller, Injectable, Get } from '@nestjs/common'
|
||||||
import { InjectRepository } from '@nestjs/typeorm'
|
import { InjectRepository } from '@nestjs/typeorm'
|
||||||
import { Repository, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
|
||||||
import { FilterOperator, Paginate, PaginateQuery, paginate, Paginated } from 'nestjs-paginate'
|
import { FilterOperator, Paginate, PaginateQuery, paginate, Paginated } from 'nestjs-paginate'
|
||||||
|
import { Repository, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class CatEntity {
|
export class CatEntity {
|
||||||
@ -122,8 +122,8 @@ export class CatsService {
|
|||||||
|
|
||||||
public findAll(query: PaginateQuery): Promise<Paginated<CatEntity>> {
|
public findAll(query: PaginateQuery): Promise<Paginated<CatEntity>> {
|
||||||
return paginate(query, this.catsRepository, {
|
return paginate(query, this.catsRepository, {
|
||||||
sortableColumns: ['id', 'name', 'color'],
|
sortableColumns: ['id', 'name', 'color', 'age'],
|
||||||
searchableColumns: ['name', 'color'],
|
searchableColumns: ['name', 'color', 'age'],
|
||||||
defaultSortBy: [['id', 'DESC']],
|
defaultSortBy: [['id', 'DESC']],
|
||||||
filterableColumns: {
|
filterableColumns: {
|
||||||
age: [FilterOperator.GTE, FilterOperator.LTE],
|
age: [FilterOperator.GTE, FilterOperator.LTE],
|
||||||
@ -154,6 +154,14 @@ const paginateConfig: PaginateConfig<CatEntity> {
|
|||||||
*/
|
*/
|
||||||
sortableColumns: ['id', 'name', 'color'],
|
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
|
* Required: false
|
||||||
* Type: (keyof CatEntity)[]
|
* Type: (keyof CatEntity)[]
|
||||||
@ -169,14 +177,6 @@ const paginateConfig: PaginateConfig<CatEntity> {
|
|||||||
*/
|
*/
|
||||||
maxLimit: 20,
|
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
|
* Required: false
|
||||||
* Type: number
|
* Type: number
|
||||||
@ -194,9 +194,9 @@ const paginateConfig: PaginateConfig<CatEntity> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Required: false
|
* Required: false
|
||||||
* Type: FilterOperator - Based on TypeORM find operators
|
* Type: { [key in CatEntity]?: FilterOperator[] } - Operators based on TypeORM find operators
|
||||||
* Default: None
|
* 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] }
|
filterableColumns: { age: [FilterOperator.EQ, FilterOperator.IN] }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user