Files
starr-philproperties/models/courses/lessons.mdl.js
T
kennethobsequio bb7e8fde08 add: ver()
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-07-08 11:31:40 +08:00

29 lines
1.2 KiB
JavaScript

const { DataTypes } = require("sequelize");
const sequelize = require("../../config/db.config");
// Standalone entity — no unit_id / order_index here. A Lesson is attached to
// zero or more Units through unit_lessons, where per-unit ordering lives.
const Lesson = sequelize.define("Lesson", {
lesson_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true, hidden: true, order: 0 },
uuid: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, allowNull: false, unique: true, hidden: true, order: 0 },
title: { type: DataTypes.STRING(255), allowNull: false, label: "Title", hidden: false, order: 1 },
description: { type: DataTypes.TEXT, allowNull: true, label: "Description", hidden: false, order: 2 },
duration_seconds: { type: DataTypes.INTEGER, allowNull: true, defaultValue: 0 }, // computed from blocks on save
createdBy: { type: DataTypes.BIGINT, allowNull: true, label: "Created By" },
updatedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Updated By" },
deletedBy: { type: DataTypes.BIGINT, allowNull: true, label: "Deleted By" },
}, {
tableName: "lessons",
timestamps: true,
paranoid: true,
indexes: [
{ fields: ["uuid"] },
{ fields: ["deletedAt"] },
],
});
module.exports = Lesson;