Commit cc24bf3d authored by rlacko's avatar rlacko 💬
Browse files

get one activity

parent 411256a0
......@@ -90,7 +90,7 @@ exports.default.createOne = async (req, res) => {
}
return res.status(422).json({ messages })
}
res.status(500).json({ message: err.message }).end()
return res.status(500).json({ message: err.message }).end()
}
}
......@@ -99,19 +99,22 @@ exports.default.getOne = async (req, res) => {
const activity = await Activity.findOne({ _id: req.params.id })
.populate({
path: 'comment',
populate: { path: 'creator', select: '-_id fullName nickName' },
select: '_id creator text createdAt',
})
.populate({
path: 'attendance',
select: '_id user state',
})
.select('-_id -__v')
.lean()
.exec()
if (!activity) {
res.status(404).json({ message: 'No such activity.' }).end()
}
if (!activity)
return res.status(404).json({ messages: ['No such activity.'] })
res.status(200).json({ data: activity }).end()
return res.status(200).json({ data: activity }).end()
} catch (err) {
res.status(500).json({ message: err.message }).end()
return res.status(500).json({ message: err.message }).end()
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment