From a81f3f0c5aafb9f048774d4aa2855a8c0d930bfe Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Wed, 4 Dec 2024 09:00:50 +0100 Subject: [PATCH] fix: attach botStats and nlpSampleEnity to the lifecyclehook --- api/src/analytics/schemas/bot-stats.schema.ts | 5 +++-- api/src/nlp/schemas/nlp-sample-entity.schema.ts | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/src/analytics/schemas/bot-stats.schema.ts b/api/src/analytics/schemas/bot-stats.schema.ts index 4bdb0a3d..37a6a44e 100644 --- a/api/src/analytics/schemas/bot-stats.schema.ts +++ b/api/src/analytics/schemas/bot-stats.schema.ts @@ -9,6 +9,7 @@ import { ModelDefinition, Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { BaseSchema } from '@/utils/generics/base-schema'; +import { LifecycleHookManager } from '@/utils/generics/lifecycle-hook-manager'; import { THydratedDocument } from '@/utils/types/filter.types'; export enum BotStatsType { @@ -115,9 +116,9 @@ export class BotStats extends BaseSchema { export type BotStatsDocument = THydratedDocument; -export const BotStatsModel: ModelDefinition = { +export const BotStatsModel: ModelDefinition = LifecycleHookManager.attach({ name: BotStats.name, schema: SchemaFactory.createForClass(BotStats), -}; +}); export default BotStatsModel.schema; diff --git a/api/src/nlp/schemas/nlp-sample-entity.schema.ts b/api/src/nlp/schemas/nlp-sample-entity.schema.ts index 31c2f66c..cfe25c3e 100644 --- a/api/src/nlp/schemas/nlp-sample-entity.schema.ts +++ b/api/src/nlp/schemas/nlp-sample-entity.schema.ts @@ -11,6 +11,7 @@ import { Transform, Type } from 'class-transformer'; import { Schema as MongooseSchema } from 'mongoose'; import { BaseSchema } from '@/utils/generics/base-schema'; +import { LifecycleHookManager } from '@/utils/generics/lifecycle-hook-manager'; import { TFilterPopulateFields, THydratedDocument, @@ -103,10 +104,11 @@ export class NlpSampleEntityFull extends NlpSampleEntityStub { export type NlpSampleEntityDocument = THydratedDocument; -export const NlpSampleEntityModel: ModelDefinition = { - name: NlpSampleEntity.name, - schema: SchemaFactory.createForClass(NlpSampleEntityStub), -}; +export const NlpSampleEntityModel: ModelDefinition = + LifecycleHookManager.attach({ + name: NlpSampleEntity.name, + schema: SchemaFactory.createForClass(NlpSampleEntityStub), + }); export default NlpSampleEntityModel.schema;