mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-25 16:19:44 +02:00
remove pages (#27)
* remove pages * requested changes and unit tests * update * fix unit test * requested changes * add confirmation * remove deeply * remove log * bugfix * update placeholder
This commit is contained in:
parent
d872e78339
commit
ccd627151f
20 changed files with 265 additions and 44 deletions
|
@ -186,6 +186,10 @@ class Pages {
|
|||
throw new Error('Page with given id does not exist');
|
||||
}
|
||||
|
||||
const alias = await Alias.get(page.uri);
|
||||
|
||||
await alias.destroy();
|
||||
|
||||
return page.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,20 @@ class PagesOrder {
|
|||
pageOrder.putAbove(currentPageId, putAbovePageId);
|
||||
await pageOrder.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parentId
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
static async remove(parentId) {
|
||||
const order = await Model.get(parentId);
|
||||
|
||||
if (!order._id) {
|
||||
throw new Error('Page with given id does not contain order');
|
||||
}
|
||||
|
||||
return order.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PagesOrder;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue