1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 11:39:36 +02:00
flame/controllers/categories/reorderCategories.js

22 lines
542 B
JavaScript

const asyncWrapper = require('../../middleware/asyncWrapper');
const Category = require('../../models/Category');
// @desc Reorder categories
// @route PUT /api/categories/0/reorder
// @access Public
const reorderCategories = asyncWrapper(async (req, res, next) => {
req.body.categories.forEach(async ({ id, orderId }) => {
await Category.update(
{ orderId },
{
where: { id },
}
);
});
res.status(200).json({
success: true,
data: {},
});
});
module.exports = reorderCategories;