Added move document feature

This commit is contained in:
NGPixel
2016-09-09 19:22:18 -04:00
parent f0916dcfe6
commit 492bb9efa6
16 changed files with 207 additions and 52 deletions

View File

@@ -174,4 +174,33 @@ router.get('/*', (req, res, next) => {
});
/**
* Move document
*/
router.put('/*', (req, res, next) => {
let safePath = entries.parsePath(req.path);
if(_.isEmpty(req.body.move)) {
return res.json({
ok: false,
error: 'Invalid document action call.'
});
}
let safeNewPath = entries.parsePath(req.body.move);
entries.move(safePath, safeNewPath).then(() => {
res.json({
ok: true
});
}).catch((err) => {
res.json({
ok: false,
error: err.message
});
});
});
module.exports = router;