updated models

This commit is contained in:
bill bittner 2017-09-15 14:41:47 -07:00
parent 866bfda293
commit 242248c4f6
5 changed files with 64 additions and 0 deletions

5
auth/authentication.js Normal file
View file

@ -0,0 +1,5 @@
module.exports = {
isAuthenticated (req, res, next) {
},
};

View file

@ -87,5 +87,15 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
freezeTableName: true, freezeTableName: true,
} }
); );
Certificate.associate = db => {
Certificate.belongsTo(db.User, {
onDelete : 'cascade',
foreignKey: {
allowNull: true,
},
});
};
return Certificate; return Certificate;
}; };

View file

@ -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; return Claim;
}; };

View file

@ -52,6 +52,13 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => {
File.associate = db => { File.associate = db => {
File.hasMany(db.Request); File.hasMany(db.Request);
File.belongsTo(db.User, {
onDelete : 'cascade',
foreignKey: {
allowNull: true,
},
});
File.hasOne(db.Claim);
}; };
return File; return File;

33
models/user.js Normal file
View file

@ -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;
};