mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-24 05:39:35 +02:00
Bookmarks controller
This commit is contained in:
parent
100f274d96
commit
27250dc850
7 changed files with 118 additions and 7 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue