update
This commit is contained in:
81
models/Story.js
Normal file
81
models/Story.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
/**
|
||||
* Story Model
|
||||
* Table: stories
|
||||
* Stores story data with metadata, vocabulary, context, grades, and tags
|
||||
*/
|
||||
const Story = sequelize.define('stories', {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
comment: 'Unique identifier for the story (UUID)'
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: false,
|
||||
comment: 'Story title/name'
|
||||
},
|
||||
logo: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
comment: 'URL to story logo/thumbnail image'
|
||||
},
|
||||
vocabulary: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: 'Array of vocabulary words used in the story'
|
||||
},
|
||||
context: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: 'Array of story context objects with images, text, audio data'
|
||||
},
|
||||
grade: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: 'Array of grade levels (e.g., ["Grade 1", "Grade 2"])'
|
||||
},
|
||||
tag: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: 'Array of tags for categorization (e.g., ["adventure", "friendship"])'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: 'Record creation timestamp'
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: 'Record last update timestamp'
|
||||
}
|
||||
}, {
|
||||
tableName: 'stories',
|
||||
timestamps: true,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_name',
|
||||
fields: ['name']
|
||||
},
|
||||
{
|
||||
name: 'idx_created_at',
|
||||
fields: ['created_at']
|
||||
}
|
||||
],
|
||||
charset: 'utf8mb4',
|
||||
collate: 'utf8mb4_unicode_ci'
|
||||
});
|
||||
|
||||
module.exports = Story;
|
||||
Reference in New Issue
Block a user