mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
const { DataTypes } = require("sequelize");
|
|
const sequelize = require("../../config/db.config");
|
|
|
|
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 },
|
|
unit_id: { type: DataTypes.BIGINT, allowNull: false, 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
|
|
|
|
order_index: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, label: "Order", hidden: false, order: 3 },
|
|
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: ["unit_id"] },
|
|
{ fields: ["order_index"] },
|
|
{ fields: ["deletedAt"] },
|
|
],
|
|
});
|
|
|
|
module.exports = Lesson; |