import { Model } from 'mongoose' ; import { Injectable , Inject } from '@nestjs/common' ; import { CreateModelDto , AIDModel } from './model.schema' ; @ Injectable ( ) export class ModelService { constructor ( @ Inject ( 'AID_Model' ) private aidModelModel ) { } async create ( createModelDto ) { const createdModel = new this . aidModelModel ( createModelDto ) ; return createdModel . save ( ) ; } async findAll ( ) { return this . aidModelModel . find ( ) . exec ( ) ; } async findByKeyword ( keyword ) { return this . aidModelModel . find ( { name : new RegExp ( keyword , 'i' ) } ) . exec ( ) ; } async findById ( id ) { return this . aidModelModel . findById ( id ) . exec ( ) ; } async count ( ) { return this . aidModelModel . estimatedDocumentCount ( ) . exec ( ) ; } }