mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-20 20:19:35 +02:00
parent
6f44200a3c
commit
31cf2bc5ad
24 changed files with 1772 additions and 939 deletions
|
@ -42,12 +42,16 @@ exports.getCategories = asyncWrapper(async (req, res, next) => {
|
|||
where: { key: 'useOrdering' },
|
||||
});
|
||||
|
||||
const orderType = useOrdering ? useOrdering.value : 'createdAt';
|
||||
const orderType = useOrdering ? useOrdering.value : "createdAt";
|
||||
let categories;
|
||||
|
||||
if (orderType == 'name') {
|
||||
if (orderType == "name") {
|
||||
categories = await Category.findAll({
|
||||
include: [
|
||||
{
|
||||
model: App,
|
||||
as: 'apps',
|
||||
},
|
||||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
|
@ -58,6 +62,10 @@ exports.getCategories = asyncWrapper(async (req, res, next) => {
|
|||
} else {
|
||||
categories = await Category.findAll({
|
||||
include: [
|
||||
{
|
||||
model: App,
|
||||
as: 'apps',
|
||||
},
|
||||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
|
@ -80,6 +88,10 @@ exports.getCategory = asyncWrapper(async (req, res, next) => {
|
|||
const category = await Category.findOne({
|
||||
where: { id: req.params.id },
|
||||
include: [
|
||||
{
|
||||
model: App,
|
||||
as: 'apps',
|
||||
},
|
||||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
|
@ -134,6 +146,10 @@ exports.deleteCategory = asyncWrapper(async (req, res, next) => {
|
|||
const category = await Category.findOne({
|
||||
where: { id: req.params.id },
|
||||
include: [
|
||||
{
|
||||
model: App,
|
||||
as: 'apps',
|
||||
},
|
||||
{
|
||||
model: Bookmark,
|
||||
as: 'bookmarks',
|
||||
|
@ -150,6 +166,12 @@ exports.deleteCategory = asyncWrapper(async (req, res, next) => {
|
|||
);
|
||||
}
|
||||
|
||||
category.apps.forEach(async (app) => {
|
||||
await App.destroy({
|
||||
where: { id: app.id },
|
||||
});
|
||||
});
|
||||
|
||||
category.bookmarks.forEach(async (bookmark) => {
|
||||
await Bookmark.destroy({
|
||||
where: { id: bookmark.id },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue