I want to pass collection name in req.body and query the collection with that name .I tried this but its not working in mongoose
router.get('/data',(req,res)=>{
var mySchema="User"; // i will get it from req.body.model
mySchema.find({},(err,docs)=>{
if(err) throw err;
res.json({
success:true,
data:docs
});
});
});