B: Added People and Credit Models for entry crew and cast
This commit is contained in:
1 parent
6bf27e5519
commit
ef9e1911f9
4 files changed
+70
-1
No files matched your search
@@ -14,6 +14,8 @@ const EntryGenre = require('../models/EntryGenre');
|
||||
const Media = require('../models/Media');
|
||||
const Network = require('../models/Network');
|
||||
const EntryNetwork = require('../models/EntryNetwork');
|
||||
const People = require('../models/People');
|
||||
const Credit = require('../models/Credit');
|
||||
|
||||
|
||||
// ? one to one
|
||||
@@ -191,4 +193,12 @@ EpisodeSeen.belongsTo(Entry, { foreignKey: 'entry_id' });
|
||||
|
||||
// * ----
|
||||
Franchise.hasMany(Entry, { foreignKey: 'franchise_id' });
|
||||
Entry.belongsTo(Franchise, { foreignKey: 'franchise_id' });
|
||||
Entry.belongsTo(Franchise, { foreignKey: 'franchise_id' });
|
||||
|
||||
// * ENTRY & Credit - ONE TO MANY
|
||||
Entry.hasMany(Credit, { foreignKey: 'entry_id', as: 'credits', onDelete: 'CASCADE', });
|
||||
Credit.belongsTo(Entry, { foreignKey: 'entry_id', as: 'entry' });
|
||||
|
||||
// * PEOPLE & CAST - ONE TO MANY
|
||||
People.hasMany(Credit, { foreignKey: 'people_id', as: 'roles', onDelete: 'CASCADE', });
|
||||
Credit.belongsTo(People, { foreignKey: 'people_id', as: 'person' });
|
||||
@@ -0,0 +1,25 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
|
||||
const Credit = sequelize.define("credits",
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
tmdb_credit_id: { type: DataTypes.STRING(100) },
|
||||
|
||||
adult: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
profile_path: { type: DataTypes.STRING(200), field: 'profile_path' },
|
||||
|
||||
character: { type: DataTypes.STRING(100) },
|
||||
order: { type: DataTypes.INTEGER },
|
||||
|
||||
cast_type: { type: DataTypes.ENUM('cast', 'crew'), field: 'cast_type', defaultValue: 'cast' },
|
||||
department: { type: DataTypes.STRING(100) },
|
||||
job: { type: DataTypes.STRING(100) },
|
||||
|
||||
entry_id: { type: DataTypes.INTEGER, field: 'entry_id' },
|
||||
people_id: { type: DataTypes.INTEGER, field: 'people_id' },
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = Credit;
|
||||
@@ -19,6 +19,7 @@ const Entry = sequelize.define("entry",
|
||||
network_studio: { type: DataTypes.STRING(40), field: 'network_studio' },
|
||||
collection_id: { type: DataTypes.INTEGER, field: 'collection_id' },
|
||||
max_cast: { type: DataTypes.INTEGER, field: 'max_cast', defaultValue: 10 },
|
||||
credit_fetched: { type: DataTypes.BOOLEAN, defaultValue: false, field: 'is_tvseries' },
|
||||
|
||||
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
favorit: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
|
||||
const People = sequelize.define("peoples",
|
||||
{
|
||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||
|
||||
tmdb_id: { type: DataTypes.STRING(100) },
|
||||
|
||||
name: { type: DataTypes.STRING(100) },
|
||||
birthday: { type: DataTypes.DATEONLY },
|
||||
deathday: { type: DataTypes.DATEONLY, allowNull: true },
|
||||
gender: { type: DataTypes.INTEGER },
|
||||
|
||||
biography: { type: DataTypes.TEXT },
|
||||
place_of_birth: { type: DataTypes.STRING(100), field: 'place_of_birth' },
|
||||
|
||||
adult: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
popularity: { type: DataTypes.FLOAT },
|
||||
|
||||
known_for_department: { type: DataTypes.STRING(50), field: 'known_for_department' },
|
||||
homepage: { type: DataTypes.STRING(200), allowNull: true },
|
||||
|
||||
imdb_id: { type: DataTypes.STRING(20), field: 'imdb_id' },
|
||||
profile_path: { type: DataTypes.STRING(200), field: 'profile_path' },
|
||||
|
||||
last_fetch: { type: DataTypes.DATEONLY, field: 'last_fetch' },
|
||||
profile_update: { type: DataTypes.DATEONLY, field: 'profile_update' },
|
||||
fully_fetched: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = People;
|
||||
Reference in new issue
Block a user