Răsfoiți Sursa

Add field (isDeleted)

Shun Miyazawa 1 an în urmă
părinte
comite
6a505a488a
1 a modificat fișierele cu 11 adăugiri și 0 ștergeri
  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);