diff --git a/auth/authentication.js b/auth/authentication.js new file mode 100644 index 00000000..294e273e --- /dev/null +++ b/auth/authentication.js @@ -0,0 +1,5 @@ +module.exports = { + isAuthenticated (req, res, next) { + + }, +}; diff --git a/models/certificate.js b/models/certificate.js index 702e8783..f8e8784d 100644 --- a/models/certificate.js +++ b/models/certificate.js @@ -87,5 +87,15 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D freezeTableName: true, } ); + + Certificate.associate = db => { + Certificate.belongsTo(db.User, { + onDelete : 'cascade', + foreignKey: { + allowNull: true, + }, + }); + }; + return Certificate; }; diff --git a/models/claim.js b/models/claim.js index b6a72a92..ab35576b 100644 --- a/models/claim.js +++ b/models/claim.js @@ -140,5 +140,14 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D } ); + Claim.associate = db => { + Claim.belongsTo(db.File, { + onDelete : 'cascade', + foreignKey: { + allowNull: true, + }, + }); + }; + return Claim; }; diff --git a/models/file.js b/models/file.js index faabf142..dbe74cf4 100644 --- a/models/file.js +++ b/models/file.js @@ -52,6 +52,13 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => { File.associate = db => { File.hasMany(db.Request); + File.belongsTo(db.User, { + onDelete : 'cascade', + foreignKey: { + allowNull: true, + }, + }); + File.hasOne(db.Claim); }; return File; diff --git a/models/user.js b/models/user.js new file mode 100644 index 00000000..d9acb6ee --- /dev/null +++ b/models/user.js @@ -0,0 +1,33 @@ +module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => { + const User = sequelize.define( + 'User', + { + channelName: { + type : STRING, + allowNull: false, + }, + channelClaimId: { + type : STRING, + allowNull: false, + }, + password: { + type : STRING, + allowNull: false, + }, + email: { + type : STRING, + allowNull: false, + }, + }, + { + freezeTableName: true, + } + ); + + User.associate = db => { + User.hasMany(db.File); + User.hasOne(db.Certificate); + }; + + return User; +};