1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-23 21:29:37 +02:00
flame/models/associateModels.js

25 lines
518 B
JavaScript
Raw Normal View History

2021-05-22 19:04:34 +02:00
const Category = require('./Category');
const App = require('./App');
2021-05-22 19:04:34 +02:00
const Bookmark = require('./Bookmark');
const associateModels = () => {
// Category <> App
Category.hasMany(App, {
as: 'apps',
foreignKey: 'categoryId'
});
App.belongsTo(Category, { foreignKey: 'categoryId' });
// Category <> Bookmark
2021-05-22 19:04:34 +02:00
Category.hasMany(Bookmark, {
foreignKey: 'categoryId',
as: 'bookmarks'
});
Bookmark.belongsTo(Category, {
2021-05-22 19:04:34 +02:00
foreignKey: 'categoryId'
});
}
module.exports = associateModels;