From 3e568b0768162eb87d3abc9e3854f02631ce9968 Mon Sep 17 00:00:00 2001 From: Saransh Balyan Date: Fri, 13 Dec 2024 03:20:29 +0530 Subject: [PATCH] config --- User/Models/Config.schema.js | 19 +++++++++++++++---- Utils/Mongo/BaseController.js | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/User/Models/Config.schema.js b/User/Models/Config.schema.js index 5778251..847ab15 100644 --- a/User/Models/Config.schema.js +++ b/User/Models/Config.schema.js @@ -1,11 +1,22 @@ -import { Schema } from 'mongoose'; +import mongoose from 'mongoose'; import BaseSchema from '#utils/Mongo/BaseSchema.js'; const Config = BaseSchema({ - user: { - ref: 'users', - type: Schema.Types.ObjectId + data: { + required: 'Config data is required', + trim: true, + type: mongoose.Schema.Types.Mixed + }, + name: { + required: 'Config name is required', + trim: true, + type: String + }, + tenant: { + required: 'Tenant is required', + trim: true, + type: String } }); diff --git a/Utils/Mongo/BaseController.js b/Utils/Mongo/BaseController.js index bc9aa3e..10e5d45 100644 --- a/Utils/Mongo/BaseController.js +++ b/Utils/Mongo/BaseController.js @@ -29,7 +29,7 @@ const BaseController = (schema) => { const getAllFromSchema = async (req, res) => { try { - const result = await req.models[schema].find(); + const result = await req.models[schema].find({ ...req.body || {} }); return res.status(200).json(result); } catch (err) { getError(err, res);