Files
yourpart3/backend/models/community/blog.js
Torsten Schulz (local) 1ab9407e79
All checks were successful
Deploy to production / deploy (push) Successful in 2m56s
Refactor code structure for improved readability and maintainability; optimize performance across multiple modules.
2026-07-21 09:08:15 +02:00

56 lines
1.1 KiB
JavaScript
Executable File

import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../utils/sequelize.js';
class Blog extends Model {}
Blog.init({
userId: {
type: DataTypes.INTEGER,
allowNull: false,
field: 'user_id'
},
title: {
type: DataTypes.STRING(255),
allowNull: false},
description: {
type: DataTypes.TEXT,
allowNull: true},
// 'public' or 'logged_in'
visibility: {
type: DataTypes.STRING(20),
allowNull: false,
defaultValue: 'public'},
ageMin: {
type: DataTypes.INTEGER,
allowNull: true,
field: 'age_min'
},
ageMax: {
type: DataTypes.INTEGER,
allowNull: true,
field: 'age_max'
},
// 'm' | 'f' | null; comma-separated for future-proofing (e.g., 'm,f')
genders: {
type: DataTypes.STRING(10),
allowNull: true},
createdAt: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
field: 'created_at'
},
updatedAt: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
field: 'updated_at'
}
}, {
sequelize,
modelName: 'Blog',
tableName: 'blog',
schema: 'community',
timestamps: true,
underscored: true});
export default Blog;