feat: Adding meta-groups and meta-data endpoints

This commit is contained in:
2023-10-06 00:39:37 -06:00
parent ce3ec074eb
commit 6c0a3a53d2
7 changed files with 97 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
"use strict";
const { ROOT_PATH, LIB_PATH, MODELS_PATH, HANDLERS_PATH } = process.env;
const { getPagination , queryPage } = require( `${ROOT_PATH}/${LIB_PATH}/Misc.js` );
const Model = require( `${ROOT_PATH}/${MODELS_PATH}/meta-groups.model.js` );
const getMetaGroupsList = async(req, res) => {
const { page , elements } = getPagination( req.query );
const retVal = await queryPage( page , elements, Model );
res.send( retVal );
};
const findMetaGroupsList = async(req, res) => {
let filter=null;
if( req.query.regex ){
const re = new RegExp( req.query.regex );
filter = { "group_label" : { $regex: re, $options: 'i' }};
}
const { page , elements } = getPagination( req.query );
const retVal = await queryPage( page, elements, Model, filter );
res.send( retVal );
};
const getMetaGroups = async(req, res) => {
const retVal = await Model.findById( req.params.id );
res.send( retVal );
};
module.exports = { getMetaGroupsList, findMetaGroupsList, getMetaGroups };