AI-Tennis-Coach/server/model/training.js
2025-02-11 11:23:59 +05:30

57 lines
1.3 KiB
JavaScript

import { sequelize } from './../loaders/index.js';
import { DataTypes } from 'sequelize';
const Training = sequelize.define('training', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
user_id: {
type: DataTypes.INTEGER,
allowNull: false,
},
drills: {
type: DataTypes.ARRAY(DataTypes.STRING), // Defines an array of strings,
allowNull: true,
},
recommendation: {
type: DataTypes.TEXT,
allowNull: true,
},
videos: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true,
},
yoga_exercises: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true,
},
weekly_plan: {
type: DataTypes.JSONB, // Defines a JSONB column,
allowNull: true,
},
videos_watched: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true,
},
}, {
tableName: 'training_content', // Define the name of the table
});
// Sync the model with the database
const syncDb = async () => {
try {
await sequelize.sync({ alter: false });
console.log('training table created (or already exists)');
} catch (err) {
console.error('Error syncing the database:', err);
}
};
// Call the sync function
syncDb();
export { Training };