update
This commit is contained in:
90
models/Vocab.js
Normal file
90
models/Vocab.js
Normal file
@@ -0,0 +1,90 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const Vocab = sequelize.define('Vocab', {
|
||||
vocab_id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for vocabulary entry'
|
||||
},
|
||||
vocab_code: {
|
||||
type: DataTypes.STRING(50),
|
||||
unique: true,
|
||||
allowNull: false,
|
||||
comment: 'Unique code for vocabulary (e.g., vocab-001-eat)'
|
||||
},
|
||||
base_word: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
comment: 'Base form of the word'
|
||||
},
|
||||
translation: {
|
||||
type: DataTypes.STRING(200),
|
||||
allowNull: false,
|
||||
comment: 'Vietnamese translation'
|
||||
},
|
||||
difficulty_score: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 1,
|
||||
comment: 'Difficulty level (1-10)'
|
||||
},
|
||||
category: {
|
||||
type: DataTypes.STRING(100),
|
||||
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
||||
},
|
||||
images: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
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
|
||||
}
|
||||
}, {
|
||||
tableName: 'vocab',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_vocab_code',
|
||||
fields: ['vocab_code']
|
||||
},
|
||||
{
|
||||
name: 'idx_base_word',
|
||||
fields: ['base_word']
|
||||
},
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: ['category']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = Vocab;
|
||||
Reference in New Issue
Block a user