From 2e62b41e23cf8b245761a64384b97500c716d78f Mon Sep 17 00:00:00 2001 From: Saransh Balyan Date: Sat, 14 Dec 2024 01:14:42 +0530 Subject: [PATCH] . --- Utils/Mongo/BaseController.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utils/Mongo/BaseController.js b/Utils/Mongo/BaseController.js index 3c75802..71687d2 100644 --- a/Utils/Mongo/BaseController.js +++ b/Utils/Mongo/BaseController.js @@ -5,9 +5,8 @@ import getError from '#utils/error.js'; const BaseController = (schema) => { const getCreateOrUpdateFromSchema = async (req, res) => { try { - const { id } = req.body; const result = await req.models[schema].findOneAndUpdate( - { _id: id || new mongoose.Types.ObjectId() }, + { _id: req.body._id || new mongoose.Types.ObjectId() }, { ...req.body }, { new: true, upsert: true });