mirror of
https://github.com/pawelmalak/flame.git
synced 2025-04-25 06:17:12 -04:00
25 lines
No EOL
518 B
JavaScript
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; |