import { Injectable } from '@nestjs/common' ; import { InjectModel } from '@nestjs/sequelize' ; import { CatDTO } from './cat.dto' ; import { Cat } from './cat.model' ; @ Injectable ( ) export class CatsService { constructor ( @ InjectModel ( Cat ) private readonly catsRepo ) { } async getCats ( ) { return this . catsRepo . findAll ( ) ; } async getCat ( id ) { return this . catsRepo . findOne ( { where : { id , } , } ) ; } async addCat ( cat ) { return this . catsRepo . create ( cat as any ) ; } async removeCat ( id ) { const cat = await this . getCat ( id ) ; await cat . destroy ( ) ; } }