combine.fm/models/album.cjs
2020-01-18 10:19:20 +00:00

35 lines
818 B
JavaScript

module.exports = function (sequelize, DataTypes) {
const Album = sequelize.define('album', {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
externalId: { type: DataTypes.STRING(50), index: true }, // eslint-disable-line new-cap
service: DataTypes.ENUM( // eslint-disable-line new-cap
'deezer',
'google',
'itunes',
'spotify',
'xbox',
'youtube'
),
name: DataTypes.TEXT,
artistId: DataTypes.INTEGER,
}, {
paranoid: true,
indexes: [
{
fields: ['externalId', 'service'],
},
],
getterMethods: {
type() {
return 'album';
},
},
});
Album.associate = function associate(models) {
Album.hasMany(models.match);
Album.belongsTo(models.artist);
};
return Album;
}