combine.fm/models/match.js
Jonathan Cremin 7bb0497ff4 Migrate all the things
* Migrates from Mongo to Postgres.
* Migrates from JSPM to Webpack.
* Migrates from React to Vuejs.
* Migrates from Bootstrap to Bulma.

Also:
* Fixes rendering of meta data in the document head tag.
2016-10-23 21:36:23 +01:00

35 lines
896 B
JavaScript

export default function (sequelize, DataTypes) {
const Match = sequelize.define('match', {
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
trackId: DataTypes.INTEGER,
albumId: DataTypes.INTEGER,
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,
streamUrl: DataTypes.TEXT,
purchaseUrl: DataTypes.TEXT,
artworkSmall: DataTypes.TEXT,
artworkLarge: DataTypes.TEXT,
}, {
paranoid: true,
indexes: [
{
fields: ['externalId', 'service'],
},
],
getterMethods: {
type() {
return this.getDataValue('trackId') ? 'track' : 'album';
},
},
});
return Match;
}