Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import sequelize from 'sequelize';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import markTypes from '../config/markTypes.js';
|
||||
|
||||
const { DataTypes, Model } = sequelize;
|
||||
|
||||
export default class Mark extends Model {
|
||||
static initialize(sequelize) {
|
||||
Mark.init(
|
||||
{
|
||||
id: { type: DataTypes.UUID, primaryKey: true },
|
||||
|
||||
markType: {
|
||||
type: DataTypes.TINYINT.UNSIGNED,
|
||||
allowNull: false,
|
||||
validate: { isIn: [Object.values(markTypes)] },
|
||||
},
|
||||
|
||||
mark: { type: DataTypes.TINYINT.UNSIGNED, validate: { min: 0, max: 10 } },
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Mark',
|
||||
tableName: 'marks',
|
||||
}
|
||||
);
|
||||
|
||||
Mark.beforeCreate(m => {
|
||||
m.id = uuidv4();
|
||||
});
|
||||
|
||||
Mark.beforeBulkCreate(ms => {
|
||||
for (const m of ms) m.id = uuidv4();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user