@imagineapps/nest-criteria
v0.0.19
Published
Abstração de filtro e paginação para o NestJS com TypeORM
Downloads
52
Readme
nest-criteria
Abstração de filtro e paginação para o NestJS com TypeORM
Example
TypeORM Entity
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany } from 'typeorm';
import { CriteriaFields } from '@imagineapps/nest-criteria';
@CriteriaFields({
name: ['IN', 'LIKE']
})
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@ManyToMany()
profiles: Profile[];
}
NestJS Controller
import { Controller, Get } from '@nestjs/common';
import { UseCriteria } from '@imagineapps/nest-criteria';
import { User } from './user.entity';
@Controller('users')
export class UsersController {
@Get()
async find(@UseCriteria(User) criteria: Criteria<User>): Promise<User[]> {
return criteria
.relations({
profiles: true,
})
.get();
}
}