Files
sena_db_api_layer/models/Context.js
silverpro89 aaba22b40c
All checks were successful
Deploy to Production / deploy (push) Successful in 19s
update context API
2026-02-06 11:28:06 +07:00

86 lines
2.0 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Context = sequelize.define('Context', {
uuid: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
comment: 'Unique identifier for context'
},
title: {
type: DataTypes.STRING(255),
allowNull: false,
comment: 'Title of the context item'
},
context: {
type: DataTypes.TEXT,
allowNull: true,
comment: 'Context description'
},
grade : {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 100,
comment: 'It is number of gradeX100 + unitX10 + lesson (e.g., Grade 1 Unit 2 Lesson 3 = 123)'
},
knowledge: {
type: DataTypes.TEXT,
allowNull: true,
comment: 'Additional knowledge or information'
},
type: {
type: DataTypes.STRING(50),
allowNull: false,
comment: 'Context type (e.g., vocabulary, grammar)'
},
desc: {
type: DataTypes.TEXT,
comment: 'Detailed description or requirement'
},
img_prompt: {
type: DataTypes.JSON,
comment: 'Prompt configuration object'
},
image: {
type: DataTypes.JSON,
comment: 'Array of image URLs'
},
max: {
type: DataTypes.INTEGER,
defaultValue: 1,
comment: 'Maximum number of images or items'
},
status: {
type: DataTypes.INTEGER, // Hoặc DataTypes.ENUM('DRAFT', 'ENRICHED', 'PENDING_IMAGE', ...)
defaultValue: 0,
comment: '0: Draft, 1: Enriched, 2: Prompt_Ready, 3: Generating, 4: Image_Ready, 5: Approved'
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
},
updated_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
}
}, {
tableName: 'context',
timestamps: true,
underscored: false,
createdAt: 'created_at',
updatedAt: 'updated_at',
indexes: [
{
name: 'idx_context_type',
fields: ['type']
},
{
name: 'idx_context_title',
fields: ['title']
}
]
});
module.exports = Context;