2017-06-22 08:33:03 +02:00
|
|
|
module.exports = (sequelize, { STRING, BOOLEAN, INTEGER }) => {
|
2017-06-17 22:51:30 +02:00
|
|
|
const File = sequelize.define(
|
|
|
|
'File',
|
|
|
|
{
|
|
|
|
name: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-06-20 00:25:14 +02:00
|
|
|
claimId: {
|
2017-06-17 22:51:30 +02:00
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-07-04 03:27:35 +02:00
|
|
|
address: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-06-17 22:51:30 +02:00
|
|
|
outpoint: {
|
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-06-22 08:33:03 +02:00
|
|
|
height: {
|
|
|
|
type : INTEGER,
|
|
|
|
allowNull: false,
|
|
|
|
default : 0,
|
|
|
|
},
|
2017-06-20 00:25:14 +02:00
|
|
|
fileName: {
|
2017-06-17 22:51:30 +02:00
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-06-20 00:25:14 +02:00
|
|
|
filePath: {
|
2017-06-17 22:51:30 +02:00
|
|
|
type : STRING,
|
|
|
|
allowNull: false,
|
|
|
|
},
|
2017-06-20 00:25:14 +02:00
|
|
|
fileType: {
|
2017-06-17 22:51:30 +02:00
|
|
|
type: STRING,
|
|
|
|
},
|
|
|
|
nsfw: {
|
|
|
|
type : BOOLEAN,
|
|
|
|
allowNull : false,
|
|
|
|
defaultValue: false,
|
|
|
|
},
|
2017-07-27 01:24:50 +02:00
|
|
|
trendingEligible: {
|
|
|
|
type : BOOLEAN,
|
|
|
|
allowNull : false,
|
|
|
|
defaultValue: true,
|
|
|
|
},
|
2017-06-17 22:51:30 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
freezeTableName: true,
|
|
|
|
}
|
2017-06-19 18:37:35 +02:00
|
|
|
);
|
2017-07-13 00:30:31 +02:00
|
|
|
|
|
|
|
File.associate = db => {
|
|
|
|
File.hasMany(db.Request);
|
2017-09-15 23:41:47 +02:00
|
|
|
File.belongsTo(db.User, {
|
|
|
|
onDelete : 'cascade',
|
|
|
|
foreignKey: {
|
|
|
|
allowNull: true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
File.hasOne(db.Claim);
|
2017-07-13 00:30:31 +02:00
|
|
|
};
|
|
|
|
|
2017-06-19 18:37:35 +02:00
|
|
|
return File;
|
|
|
|
};
|