Category model and controllers

This commit is contained in:
unknown
2021-05-22 19:04:34 +02:00
parent 5c948e1a68
commit 100f274d96
8 changed files with 164 additions and 4 deletions

13
models/associateModels.js Normal file
View File

@@ -0,0 +1,13 @@
const Category = require('./Category');
const Bookmark = require('./Bookmark');
const associateModels = () => {
// Category <> Bookmark
Bookmark.belongsTo(Category, { foreignKey: 'categoryId' });
Category.hasMany(Bookmark, {
as: 'bookmarks',
foreignKey: 'categoryId'
});
}
module.exports = associateModels;