2017-09-17 02:50:22 +02:00
|
|
|
module.exports = (sequelize, { STRING }) => {
|
2017-09-15 23:41:47 +02:00
|
|
|
const User = sequelize.define(
|
2017-09-17 02:50:22 +02:00
|
|
|
'User',
|
2017-09-15 23:41:47 +02:00
|
|
|
{
|
|
|
|
channelName: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
|
|
|
channelClaimId: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
|
|
|
password: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-09-19 21:54:23 +02:00
|
|
|
address: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-09-15 23:41:47 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
freezeTableName: true,
|
|
|
|
}
|
2017-09-18 19:14:06 +02:00
|
|
|
);
|
2017-09-15 23:41:47 +02:00
|
|
|
|
|
|
|
User.associate = db => {
|
|
|
|
User.hasMany(db.File);
|
|
|
|
User.hasOne(db.Certificate);
|
|
|
|
};
|
|
|
|
|
2017-09-18 19:14:06 +02:00
|
|
|
User.prototype.validPassword = (givenpassword, thispassword) => {
|
|
|
|
console.log(`${givenpassword} === ${thispassword}`);
|
|
|
|
return (givenpassword === thispassword);
|
|
|
|
};
|
|
|
|
|
2017-09-15 23:41:47 +02:00
|
|
|
return User;
|
|
|
|
};
|