fix surveys

This commit is contained in:
Swift
2024-02-24 18:21:50 +03:30
parent ce71b592dd
commit 85b95ed60d
4 changed files with 69 additions and 27 deletions
+16 -6
View File
@@ -104,12 +104,22 @@ module.exports.getAllForUser = [
module.exports.getAllForAdmin = [
(req, res) => {
Survey.find({type:req.query.type || 0})
.populate('user', 'first_name last_name')
.exec((err, data) => {
if (err) return res500(res, err)
return res.json(data)
})
// eslint-disable-next-line eqeqeq
if(req.query.type == 1){
Survey.find({type: 1 })
.exec((err, data) => {
if (err) return res500(res, err)
return res.json(data)
})
}else{
Survey.find({type: 0 })
.populate('user', 'first_name last_name')
.exec((err, data) => {
if (err) return res500(res, err)
return res.json(data)
})
}
}
]