Skip to content

Commit

Permalink
config
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh Balyan committed Dec 12, 2024
1 parent e115f80 commit 3e568b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions User/Models/Config.schema.js
Original file line number Diff line number Diff line change
@@ -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
}
});

Expand Down
2 changes: 1 addition & 1 deletion Utils/Mongo/BaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3e568b0

Please sign in to comment.