소스 검색

Add field (isDeleted)

Shun Miyazawa 1 년 전
부모
커밋
6a505a488a
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      apps/app/src/features/openai/server/models/ai-assistant.ts

+ 11 - 0
apps/app/src/features/openai/server/models/ai-assistant.ts

@@ -41,6 +41,7 @@ interface AiAssistant {
   pages: mongoose.Types.ObjectId[]
   sharingScope: AiAssistantSharingScope
   learningScope: AiAssistantLearningScope
+  isDeleted: boolean
 }
 
 interface AiAssistantDocument extends AiAssistant, Document {}
@@ -87,10 +88,20 @@ const schema = new Schema<AiAssistantDocument>(
       enum: Object.values(AiAssistantLearningScope),
       required: true,
     },
+    isDeleted: {
+      type: Boolean,
+      default: false,
+      required: true,
+    },
   },
   {
     timestamps: true,
   },
 );
 
+schema.methods.markAsDeleted = async function(): Promise<void> {
+  this.isDeleted = true;
+  await this.save();
+};
+
 export default getOrCreateModel<AiAssistantDocument, AiAssistantModel>('AiAssistant', schema);