From 9f46fbf6d86c2d6bda8f4533943884e2decf1fc9 Mon Sep 17 00:00:00 2001 From: Jweng88 <108978684+Jweng88@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:39:03 +0800 Subject: [PATCH] Remove version field in question document --- question-service/src/model/question-model.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/question-service/src/model/question-model.ts b/question-service/src/model/question-model.ts index 2524f86b61..272f484bdf 100644 --- a/question-service/src/model/question-model.ts +++ b/question-service/src/model/question-model.ts @@ -42,4 +42,9 @@ questionSchema.pre("save", async function (next) { next(); }); +// Add this option to remove __v automatically +questionSchema.set("toJSON", { + versionKey: false, // This removes the __v field +}); + export default mongoose.model("Question", questionSchema);