2023-02-22 15:21:29 +01:00
|
|
|
const { Model, DataTypes } = require('sequelize');
|
2023-02-22 14:54:35 +01:00
|
|
|
|
|
|
|
class User extends Model {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-22 15:21:29 +01:00
|
|
|
const structure = {
|
|
|
|
id: {
|
|
|
|
type: DataTypes.BIGINT,
|
|
|
|
primaryKey: true,
|
|
|
|
autoIncrement: true,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
login: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
pass: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
totp: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: true
|
|
|
|
},
|
|
|
|
totpRec: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: true
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
gpgkey: {
|
|
|
|
type: DataTypes.TEXT,
|
|
|
|
allowNull: false
|
2023-02-23 07:51:19 +01:00
|
|
|
},
|
|
|
|
accessLevel: {
|
|
|
|
type: DataTypes.SMALLINT,
|
|
|
|
allowNull: false,
|
|
|
|
defaultValue: 0
|
2023-02-22 15:21:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
User.structure = structure
|
|
|
|
|
2023-02-22 14:54:35 +01:00
|
|
|
/**
|
|
|
|
* @param {import('sequelize').Sequelize} sequelize
|
|
|
|
* @param {import('sequelize').DataTypes} DataTypes
|
2023-02-22 15:21:29 +01:00
|
|
|
* @returns User
|
2023-02-22 14:54:35 +01:00
|
|
|
*/
|
|
|
|
const init = (sequelize, DataTypes) => {
|
2023-02-22 15:21:29 +01:00
|
|
|
let user = User.init(structure, {
|
2023-02-22 14:54:35 +01:00
|
|
|
sequelize,
|
|
|
|
tableName: 'users',
|
|
|
|
tableName: 'users'
|
|
|
|
});
|
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
|
|
|
init.class = User;
|
|
|
|
module.exports = init;
|