update sentences API
All checks were successful
Deploy to Production / deploy (push) Successful in 22s

This commit is contained in:
silverpro89
2026-02-24 14:29:23 +07:00
parent cfc83c983c
commit d3da098f6f
10 changed files with 1447 additions and 19 deletions

103
models/Sentences.js Normal file
View File

@@ -0,0 +1,103 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const Sentences = sequelize.define('Sentences', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
comment: 'Unique identifier for sentence entry'
},
// Từ thực tế (wash, washes, washing, ate, eaten...)
text: {
type: DataTypes.TEXT,
allowNull: false
},
ipa : {
type: DataTypes.TEXT,
comment: 'International Phonetic Alphabet representation'
},
// Nội dung dùng chung (có thể lưu JSON để dễ quản lý hoặc dùng chung cho cả group)
vi: {
type: DataTypes.TEXT,
defaultValue: '',
comment: 'Vietnamese meaning'
},
grade : {
type: DataTypes.TEXT,
defaultValue: '0',
comment: 'Grade level (e.g., Grade 1, Grade 2)'
},
category: {
type: DataTypes.TEXT,
comment: 'Category of the sentence (e.g., Action Verbs, Nouns)'
},
topic: {
type: DataTypes.TEXT,
comment: 'Topic of the sentence (e.g., Food, Travel, Education)'
},
image_small: {
type: DataTypes.JSON,
defaultValue: [],
comment: 'Array of image URLs'
},
image_square: {
type: DataTypes.JSON,
defaultValue: [],
comment: 'Array of image URLs'
},
image_normal: {
type: DataTypes.JSON,
defaultValue: [],
comment: 'Array of image URLs'
},
audio : {
type: DataTypes.JSON,
comment: 'Array of audio URLs'
},
tags: {
type: DataTypes.JSON,
defaultValue: [],
comment: 'Array of tags for categorization'
},
usage_note: {
type: DataTypes.TEXT,
defaultValue: '',
comment: 'Lưu ý về ngữ cảnh sử dụng câu này'
},
etc : {
type: DataTypes.TEXT,
defaultValue: '',
comment: 'Các thông tin khác liên quan đến câu này (ví dụ: level, grammar points, etc.)'
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: true,
comment: 'Whether this sentence entry is active'
},
created_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
},
updated_at: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW
}
}, {
tableName: 'sentences',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
indexes: [
{
name: 'idx_sentences_text',
fields: [{ name: 'text', length: 191 }]
},
{
name: 'idx_category',
fields: [{ name: 'category', length: 191 }]
}
]
});
module.exports = Sentences;