import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/sequelize';
import { FindOptions } from 'sequelize';
import { Cid } from 'src/unid-saude/entity/cid.model';

@Injectable()
export class CidService {

    constructor(
       
        @InjectModel(Cid)
        private readonly cidModel: typeof Cid,
      ) {}

      async findAllCid(): Promise<Cid[]> {
        return this.cidModel.findAll();
      }

      async findAll(): Promise<Cid[]> {
        return Cid.findAll();
      }
    
      async searchCid(code: string): Promise<Cid[]> {
        return this.cidModel.findAll({
          where: {
               codigo: { $like: `%${code}%` },
          },
        })
      }
}
