Back: reworked the media/entry relation

This commit is contained in:
X4Lo committed 2024-09-10 21:32:46 +01:00
1 parent d06a21097f
commit b42e055691
5 files changed
+41 -30

No files matched your search

@@ -1,7 +1,7 @@
const { DataTypes } = require('sequelize');
const sequelize = require('../db/database');
const UserCollection = sequelize.define("userCollection",
const Collection = sequelize.define("userCollection",
{
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
tmdbId: { type: DataTypes.STRING(30), field: 'tmdb_id' },
@@ -19,4 +19,4 @@ const UserCollection = sequelize.define("userCollection",
}
);
module.exports = UserCollection;
module.exports = Collection;
+12 -9
View File
@@ -1,18 +1,21 @@
const { DataTypes } = require('sequelize');
const { DataTypes, Sequelize } = require('sequelize');
const sequelize = require('../db/database');
const Media = sequelize.define("media",
{
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
entryId: {
type: DataTypes.INTEGER,
references: {
model: 'Entries',
key: 'id'
},
field: 'entry_id'
},
// entryId: {
// type: DataTypes.INTEGER,
// references: {
// model: 'Entries',
// key: 'id'
// },
// field: 'entry_id'
// },
mediaable: { type: Sequelize.STRING },
mediaableId: { type: Sequelize.INTEGER, field: 'mediaable_id' },
type: { type: DataTypes.STRING(50) },
path: { type: DataTypes.STRING(200) },