mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-14 20:49:42 +03:00
Added Post and Image entities to the database.
This commit is contained in:
24
backend/libs/database/image.entity.ts
Normal file
24
backend/libs/database/image.entity.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToOne, JoinColumn } from 'typeorm';
|
||||
import { Post } from './post.entity';
|
||||
|
||||
@Entity()
|
||||
export class Image {
|
||||
constructor(props?: Partial<Image>) {
|
||||
Object.assign(this, props);
|
||||
}
|
||||
|
||||
@PrimaryColumn()
|
||||
message_id: number;
|
||||
|
||||
@Column({ nullable: false })
|
||||
post_id: number;
|
||||
|
||||
@Column({ nullable: false })
|
||||
file_id: string;
|
||||
@Column({ default: false })
|
||||
has_spoiler: boolean;
|
||||
|
||||
@OneToOne(() => Post)
|
||||
@JoinColumn({ name: 'post_id' })
|
||||
user: Post;
|
||||
}
|
||||
27
backend/libs/database/post.entity.ts
Normal file
27
backend/libs/database/post.entity.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, Timestamp, OneToOne, JoinColumn } from 'typeorm';
|
||||
import { Admin } from './admin.entity';
|
||||
@Entity()
|
||||
export class Post {
|
||||
constructor(props?: Partial<Post>) {
|
||||
Object.assign(this, props);
|
||||
}
|
||||
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
uuid: string;
|
||||
|
||||
@Column({ default: false })
|
||||
posted: boolean;
|
||||
|
||||
@Column({ nullable: false })
|
||||
from_user_id: string;
|
||||
@Column()
|
||||
text: string;
|
||||
@Column()
|
||||
media_group_id: string;
|
||||
@Column({ type: 'timestamptz' })
|
||||
timestamps: Date;
|
||||
|
||||
@OneToOne(() => Admin)
|
||||
@JoinColumn({ name: 'from_user_id' })
|
||||
user: Admin;
|
||||
}
|
||||
@@ -2,8 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { User } from './database/user.entity';
|
||||
import { Admin } from './database/admin.entity';
|
||||
import { Post } from './database/post.entity';
|
||||
import { Image } from './database/image.entity';
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([User, Admin])],
|
||||
imports: [TypeOrmModule.forFeature([User, Admin, Post, Image])],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class LibsModule {}
|
||||
|
||||
Reference in New Issue
Block a user