2023-02-22 15:21:29 +01:00
|
|
|
const { Model, DataTypes } = require('sequelize');
|
2023-02-22 14:54:35 +01:00
|
|
|
|
|
|
|
class Article extends Model {
|
2023-03-02 14:36:01 +01:00
|
|
|
/**
|
|
|
|
* @param {{
|
|
|
|
* title: string,
|
|
|
|
* body: string,
|
|
|
|
* shortText: string,
|
|
|
|
* gpgsign: string,
|
|
|
|
* as: import('./user').class
|
|
|
|
* }} data
|
|
|
|
*/
|
|
|
|
static async writenew(data) {
|
|
|
|
|
|
|
|
}
|
2023-02-22 14:54:35 +01:00
|
|
|
}
|
|
|
|
|
2023-02-22 15:21:29 +01:00
|
|
|
Article.structure = {
|
|
|
|
id: {
|
|
|
|
type: DataTypes.BIGINT(11),
|
|
|
|
primaryKey: true,
|
|
|
|
autoIncrement: true,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
shortText: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
body: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
submitted: {
|
|
|
|
type: DataTypes.BIGINT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
edited: {
|
|
|
|
type: DataTypes.BIGINT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
submitter: {
|
|
|
|
type: DataTypes.BIGINT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
gpgsign: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: true
|
2023-02-27 14:26:24 +01:00
|
|
|
},
|
|
|
|
hidden: {
|
|
|
|
type: DataTypes.BOOLEAN,
|
|
|
|
allowNull: false,
|
|
|
|
defaultValue: false
|
2023-02-22 15:21:29 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import('sequelize').Sequelize} sequelize
|
|
|
|
* @param {import('sequelize').DataTypes} DataTypes
|
|
|
|
* @returns Article
|
|
|
|
*/
|
2023-02-22 14:54:35 +01:00
|
|
|
let init = (sequelize, DataTypes) => {
|
2023-02-22 15:21:29 +01:00
|
|
|
let article = Article.init(Article.structure, {
|
2023-02-22 14:54:35 +01:00
|
|
|
sequelize,
|
|
|
|
modelName: 'Article',
|
|
|
|
tableName: 'articles'
|
|
|
|
})
|
|
|
|
article.class = Article;
|
|
|
|
|
|
|
|
return article;
|
|
|
|
}
|
|
|
|
|
|
|
|
init.class = Article;
|
|
|
|
module.exports = init;
|