Added Post and Image entities to the database.

This commit is contained in:
Errormacr
2023-11-20 15:34:05 +03:00
parent 35e72a2134
commit c76c61c23c
3 changed files with 54 additions and 1 deletions

View 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;
}

View 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;
}

View File

@@ -2,8 +2,10 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm'; import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './database/user.entity'; import { User } from './database/user.entity';
import { Admin } from './database/admin.entity'; import { Admin } from './database/admin.entity';
import { Post } from './database/post.entity';
import { Image } from './database/image.entity';
@Module({ @Module({
imports: [TypeOrmModule.forFeature([User, Admin])], imports: [TypeOrmModule.forFeature([User, Admin, Post, Image])],
exports: [TypeOrmModule], exports: [TypeOrmModule],
}) })
export class LibsModule {} export class LibsModule {}