Fixed bug with alphabetical order not working for bookmarks. Minor changes related to bookmarks form

This commit is contained in:
Paweł Malak
2021-11-26 14:04:46 +01:00
parent ec5f50aba4
commit d5610ad6be
12 changed files with 89 additions and 17 deletions

View File

@@ -18,8 +18,14 @@ const getAllCategories = asyncWrapper(async (req, res, next) => {
const order =
orderType == 'name'
? [[Sequelize.fn('lower', Sequelize.col('bookmarks.name')), 'ASC']]
: [[{ model: Bookmark, as: 'bookmarks' }, orderType, 'ASC']];
? [
[Sequelize.fn('lower', Sequelize.col('Category.name')), 'ASC'],
[Sequelize.fn('lower', Sequelize.col('bookmarks.name')), 'ASC'],
]
: [
[orderType, 'ASC'],
[{ model: Bookmark, as: 'bookmarks' }, orderType, 'ASC'],
];
categories = categories = await Category.findAll({
include: [