2021-04-24 08:38:24 -05:00
|
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
|
2022-02-26 20:07:39 -06:00
|
|
|
import { User } from './user.js';
|
|
|
|
import { id } from '../id.js';
|
|
|
|
import { DriveFile } from './drive-file.js';
|
2021-04-24 08:38:24 -05:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
export class GalleryPost {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The created date of the GalleryPost.',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The updated date of the GalleryPost.',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public updatedAt: Date;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 256,
|
|
|
|
})
|
|
|
|
public title: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 2048, nullable: true,
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public description: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'The ID of author.',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public userId: User['id'];
|
|
|
|
|
|
|
|
@ManyToOne(type => User, {
|
2021-12-09 08:58:30 -06:00
|
|
|
onDelete: 'CASCADE',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public user: User | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column({
|
|
|
|
...id(),
|
2021-12-09 08:58:30 -06:00
|
|
|
array: true, default: '{}',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public fileIds: DriveFile['id'][];
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 08:58:30 -06:00
|
|
|
comment: 'Whether the post is sensitive.',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public isSensitive: boolean;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('integer', {
|
2021-12-09 08:58:30 -06:00
|
|
|
default: 0,
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public likedCount: number;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
2021-12-09 08:58:30 -06:00
|
|
|
length: 128, array: true, default: '{}',
|
2021-04-24 08:38:24 -05:00
|
|
|
})
|
|
|
|
public tags: string[];
|
|
|
|
|
|
|
|
constructor(data: Partial<GalleryPost>) {
|
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|