mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-31 00:19:36 +02:00
parent
6f44200a3c
commit
31cf2bc5ad
24 changed files with 1772 additions and 939 deletions
|
@ -10,6 +10,10 @@ const App = sequelize.define('App', {
|
|||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
categoryId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
icon: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
|
|
|
@ -6,6 +6,10 @@ const Category = sequelize.define('Category', {
|
|||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
isPinned: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue