Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_module.update = function (req, res) {
if (!req.body.alias) req.body.alias = require('slug')(req.body.title).toLocaleLowerCase();
if (typeof req.body.category_id == 'string') {
req.body.category_id = [req.body.category_id]
}
if (typeof req.body.tags == 'string') {
req.body.tags = [req.body.tags]
}
if (!req.body.category_id) {
req.body.category_id = []
}
__models.Posts.update({key: 'article', _id: req.params.id}, req.body).exec(function (err, re) {
if (err) {
__.logger.error(err);
return _module.render_error(req, res, '500');
}