flame/models/associateModels.js
François Darveau 31cf2bc5ad Add app categories (#0)
add app categories
2021-10-11 11:00:22 -04:00

25 lines
No EOL
518 B
JavaScript

const Category = require('./Category');
const App = require('./App');
const Bookmark = require('./Bookmark');
const associateModels = () => {
// Category <> App
Category.hasMany(App, {
as: 'apps',
foreignKey: 'categoryId'
});
App.belongsTo(Category, { foreignKey: 'categoryId' });
// Category <> Bookmark
Category.hasMany(Bookmark, {
foreignKey: 'categoryId',
as: 'bookmarks'
});
Bookmark.belongsTo(Category, {
foreignKey: 'categoryId'
});
}
module.exports = associateModels;