1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-24 05:39:35 +02:00

Bookmarks controller

This commit is contained in:
unknown 2021-05-23 17:18:04 +02:00
parent 100f274d96
commit 27250dc850
7 changed files with 118 additions and 7 deletions

View file

@ -19,10 +19,12 @@ exports.createCategory = asyncWrapper(async (req, res, next) => {
// @route GET /api/categories
// @access Public
exports.getCategories = asyncWrapper(async (req, res, next) => {
// const categories = await Category.findAll({
// include: Bookmark
// });
const categories = await Category.findAll();
const categories = await Category.findAll({
include: [{
model: Bookmark,
as: 'bookmarks'
}]
});
res.status(200).json({
success: true,
@ -35,7 +37,11 @@ exports.getCategories = asyncWrapper(async (req, res, next) => {
// @access Public
exports.getCategory = asyncWrapper(async (req, res, next) => {
const category = await Category.findOne({
where: { id: req.params.id }
where: { id: req.params.id },
include: [{
model: Bookmark,
as: 'bookmarks'
}]
});
if (!category) {