summaryrefslogtreecommitdiff
path: root/src/models/entities/gallery-like.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/entities/gallery-like.ts')
-rw-r--r--src/models/entities/gallery-like.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/models/entities/gallery-like.ts b/src/models/entities/gallery-like.ts
new file mode 100644
index 0000000000..7d084a2275
--- /dev/null
+++ b/src/models/entities/gallery-like.ts
@@ -0,0 +1,33 @@
+import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
+import { User } from './user';
+import { id } from '../id';
+import { GalleryPost } from './gallery-post';
+
+@Entity()
+@Index(['userId', 'postId'], { unique: true })
+export class GalleryLike {
+ @PrimaryColumn(id())
+ public id: string;
+
+ @Column('timestamp with time zone')
+ public createdAt: Date;
+
+ @Index()
+ @Column(id())
+ public userId: User['id'];
+
+ @ManyToOne(type => User, {
+ onDelete: 'CASCADE'
+ })
+ @JoinColumn()
+ public user: User | null;
+
+ @Column(id())
+ public postId: GalleryPost['id'];
+
+ @ManyToOne(type => GalleryPost, {
+ onDelete: 'CASCADE'
+ })
+ @JoinColumn()
+ public post: GalleryPost | null;
+}