kannon/models/AlbumToArtist.js

35 lines
776 B
JavaScript
Raw Normal View History

2022-06-03 17:04:44 +02:00
const path = require('path');
const { DataTypes } = require('sequelize');
2022-06-03 17:04:44 +02:00
const Base = require('./Base.js');
2022-06-03 14:52:35 +02:00
2022-06-03 17:04:44 +02:00
const tableName = path.basename(__filename, '.js').toLowerCase();
2022-06-03 14:52:35 +02:00
2022-06-03 17:04:44 +02:00
class AlbumToArtist extends Base {
2022-06-03 14:52:35 +02:00
2022-06-03 17:04:44 +02:00
constructor(album, artist) {
super();
this.tableName = tableName;
2022-06-15 16:56:38 +02:00
this.relationTable = true;
2022-06-03 17:04:44 +02:00
this.album = album;
this.artist = artist;
}
2022-06-03 17:04:44 +02:00
isValid() {
return this.album !== undefined || this.artist !== undefined;
}
2022-06-03 14:52:35 +02:00
2022-06-03 17:04:44 +02:00
async getModel() {
return database.connection.define(tableName, {
album: DataTypes.INTEGER,
artist: DataTypes.INTEGER
},
{
freezeTableName: true
}
);
}
2022-06-03 14:52:35 +02:00
}
2022-06-03 17:04:44 +02:00
module.exports = AlbumToArtist;