2025-10-12 00:40:02 +07:00

40 lines
871 B
JavaScript

"use strict";
const { Model } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
class TimeEntry extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
this.belongsTo(models.User, { foreignKey: "userId" });
}
}
TimeEntry.init(
{
userId: {
type: DataTypes.INTEGER,
allowNull: false,
},
date: {
type: DataTypes.DATE,
allowNull: false,
},
reason: {
type: DataTypes.STRING,
allowNull: false,
},
hours: {
type: DataTypes.DECIMAL,
allowNull: false,
},
},
{
sequelize,
modelName: "TimeEntry",
}
);
return TimeEntry;
};