Skip to content

Instantly share code, notes, and snippets.

@A
Created March 20, 2014 06:15
Show Gist options
  • Save A/9658235 to your computer and use it in GitHub Desktop.
Save A/9658235 to your computer and use it in GitHub Desktop.
module.exports = function () {
return function (req, res) {
var pageNum = req.params.pageNum |0;
var querySet = {};
querySet['pages.'+pageNum] = false;
Project
.update({_id: req.params.projectID, owner: req.user._id}, {$set: querySet})
.exec(function (err, updated) {
err
? res.json(500, {error: err.message})
: updated
? Project
.update({_id: req.params.projectID, owner: req.user._id}, {$pull: {pages: false}})
.exec(function (err) {
err
? res.json(500, {error: err.message})
: res.json(200, {});
})
: res.json(404, {});
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment