This commit is contained in:
@@ -2,102 +2,107 @@ 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'
|
||||
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.)'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: 'Trạng thái confirm (0 = chưa confirm)'
|
||||
},
|
||||
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 }]
|
||||
},
|
||||
// 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
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: [{ name: 'category', length: 191 }]
|
||||
}
|
||||
}, {
|
||||
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;
|
||||
|
||||
236
models/Vocab.js
236
models/Vocab.js
@@ -3,121 +3,131 @@ const { sequelize } = require('../config/database');
|
||||
const Grade = require('./Grade');
|
||||
|
||||
const Vocab = sequelize.define('Vocab', {
|
||||
vocab_id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for vocabulary entry'
|
||||
vocab_id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for vocabulary entry'
|
||||
},
|
||||
// Từ thực tế (wash, washes, washing, ate, eaten...)
|
||||
text: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
},
|
||||
ipa: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'International Phonetic Alphabet representation'
|
||||
},
|
||||
// Từ gốc để nhóm lại (wash, eat...)
|
||||
base_word: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
},
|
||||
// Loại biến thể (V1, V2, V3, V_ing, Noun_Form...)
|
||||
form_key: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: 'base',
|
||||
comment: 'Form key indicating the type of word form (e.g., base, V1, V2, V3, V_ing, Noun_Form)'
|
||||
},
|
||||
// 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_number: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: 'Numeric representation of grade unit lesson as GG UU LL for easier querying and sorting'
|
||||
},
|
||||
category: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
||||
},
|
||||
topic: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Topic of the word (e.g., Food, Travel, Education)'
|
||||
},
|
||||
image_small: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_square: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_normal: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
audio: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of audio URLs'
|
||||
},
|
||||
example_sentences: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of example sentences'
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of tags for categorization'
|
||||
},
|
||||
syntax: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Syntax roles for Grammar Engine (is_subject, is_verb, is_object, is_be, is_adj, is_adv, is_article, verb_type, article_type, adv_type, position, priority, etc.)'
|
||||
},
|
||||
semantics: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Semantic constraints (can_be_subject_type, can_take_object_type, can_modify, cannot_modify, word_type, is_countable, person_type, etc.)'
|
||||
},
|
||||
constraints: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Grammar constraints (followed_by, match_subject, match_with, phonetic_rules, etc.)'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: 'Trạng thái confirm (0 = chưa confirm)'
|
||||
},
|
||||
etc: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: 'Thông tin bổ sung'
|
||||
},
|
||||
is_active: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
comment: 'Whether this vocab entry is active'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
}
|
||||
}, {
|
||||
tableName: 'vocab',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_vocab_text',
|
||||
fields: ['text']
|
||||
},
|
||||
// Từ thực tế (wash, washes, washing, ate, eaten...)
|
||||
text: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
{
|
||||
name: 'idx_base_word',
|
||||
fields: ['base_word']
|
||||
},
|
||||
ipa : {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'International Phonetic Alphabet representation'
|
||||
},
|
||||
// Từ gốc để nhóm lại (wash, eat...)
|
||||
base_word: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
index: true
|
||||
},
|
||||
// Loại biến thể (V1, V2, V3, V_ing, Noun_Form...)
|
||||
form_key: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: 'base',
|
||||
comment: 'Form key indicating the type of word form (e.g., base, V1, V2, V3, V_ing, Noun_Form)'
|
||||
},
|
||||
// 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_number: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: 'Numeric representation of grade unit lesson as GG UU LL for easier querying and sorting'
|
||||
},
|
||||
category: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
||||
},
|
||||
topic: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Topic of the word (e.g., Food, Travel, Education)'
|
||||
},
|
||||
image_small: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_square: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_normal: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
audio : {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of audio URLs'
|
||||
},
|
||||
example_sentences: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of example sentences'
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of tags for categorization'
|
||||
},
|
||||
syntax: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Syntax roles for Grammar Engine (is_subject, is_verb, is_object, is_be, is_adj, is_adv, is_article, verb_type, article_type, adv_type, position, priority, etc.)'
|
||||
},
|
||||
semantics: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Semantic constraints (can_be_subject_type, can_take_object_type, can_modify, cannot_modify, word_type, is_countable, person_type, etc.)'
|
||||
},
|
||||
constraints: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Grammar constraints (followed_by, match_subject, match_with, phonetic_rules, etc.)'
|
||||
},
|
||||
is_active: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
comment: 'Whether this vocab entry is active'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: ['category']
|
||||
}
|
||||
}, {
|
||||
tableName: 'vocab',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_vocab_text',
|
||||
fields: ['text']
|
||||
},
|
||||
{
|
||||
name: 'idx_base_word',
|
||||
fields: ['base_word']
|
||||
},
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: ['category']
|
||||
}
|
||||
]
|
||||
});
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = Vocab;
|
||||
|
||||
Reference in New Issue
Block a user