2022-06-15 16:56:38 +02:00
|
|
|
const { table } = require('console');
|
2022-06-03 17:04:44 +02:00
|
|
|
const path = require('path');
|
2022-06-01 16:20:25 +02:00
|
|
|
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-08 15:15:25 +02:00
|
|
|
class TrackToAlbum extends Base {
|
2022-06-03 14:52:35 +02:00
|
|
|
|
2022-06-03 17:04:44 +02:00
|
|
|
constructor(track, album) {
|
2022-06-08 15:06:38 +02:00
|
|
|
super();
|
2022-06-15 16:56:38 +02:00
|
|
|
this.tableName = tableName;
|
|
|
|
this.relationTable = true;
|
2022-06-03 17:04:44 +02:00
|
|
|
this.track = track;
|
|
|
|
this.album = album;
|
2022-06-01 16:20:25 +02:00
|
|
|
}
|
|
|
|
|
2022-06-03 17:04:44 +02:00
|
|
|
isValid() {
|
|
|
|
return this.track !== undefined || this.album !== undefined;
|
|
|
|
}
|
2022-06-03 14:52:35 +02:00
|
|
|
|
2022-06-03 17:04:44 +02:00
|
|
|
async getModel() {
|
|
|
|
return database.connection.define(tableName, {
|
|
|
|
track: DataTypes.INTEGER,
|
|
|
|
album: DataTypes.INTEGER
|
|
|
|
},
|
|
|
|
{
|
|
|
|
freezeTableName: true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2022-06-03 14:52:35 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-03 17:04:44 +02:00
|
|
|
module.exports = TrackToAlbum;
|