Added Docker

This commit is contained in:
Tiemen van Olst
2025-09-09 08:52:28 +02:00
parent 7f1595dddd
commit 72d9f5e642
29 changed files with 10623 additions and 193 deletions

View File

@@ -0,0 +1,37 @@
import { DataTypes } from 'sequelize';
import { sequelize } from '../index.js';
const Post = sequelize.define('Post', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: {
type: DataTypes.STRING,
allowNull: false
},
content: {
type: DataTypes.TEXT,
allowNull: true
},
published: {
type: DataTypes.BOOLEAN,
defaultValue: false
},
authorId: {
type: DataTypes.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id'
}
}
}, {
tableName: 'posts',
timestamps: true,
createdAt: 'createdAt',
updatedAt: 'updatedAt'
});
export default Post;

View File

@@ -0,0 +1,26 @@
import { DataTypes } from 'sequelize';
import { sequelize } from '../index.js';
const User = sequelize.define('User', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: true
}
}, {
tableName: 'users',
timestamps: true,
createdAt: 'createdAt',
updatedAt: 'updatedAt'
});
export default User;

View File

@@ -0,0 +1,8 @@
import User from './User.js';
import Post from './Post.js';
// Define associations
User.hasMany(Post, { foreignKey: 'authorId', as: 'posts' });
Post.belongsTo(User, { foreignKey: 'authorId', as: 'author' });
export { User, Post };