summary refs log tree commit diff
path: root/util/src/entities
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-14 19:47:02 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-14 19:47:02 +0200
commit9200fb546c1e2c12e0403a1bbfb6360946a28b1c (patch)
tree41d3730d3aa235002a844e753b27ad2a74afbce7 /util/src/entities
parent:sparkles: sticker packs (diff)
downloadserver-9200fb546c1e2c12e0403a1bbfb6360946a28b1c.tar.xz
:sparkles: sticker db entities
Diffstat (limited to 'util/src/entities')
-rw-r--r--util/src/entities/Sticker.ts19
-rw-r--r--util/src/entities/StickerPack.ts31
2 files changed, 49 insertions, 1 deletions
diff --git a/util/src/entities/Sticker.ts b/util/src/entities/Sticker.ts
index 036ff2d0..94761f60 100644
--- a/util/src/entities/Sticker.ts
+++ b/util/src/entities/Sticker.ts
@@ -1,4 +1,5 @@
-import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
+import { User } from "./User";
 import { BaseClass } from "./BaseClass";
 import { Guild } from "./Guild";
 
@@ -25,8 +26,15 @@ export class Sticker extends BaseClass {
 	tags: string;
 
 	@Column()
+	@RelationId((sticker: Sticker) => sticker.pack)
 	pack_id: string;
 
+	@JoinColumn({ name: "pack_id" })
+	@ManyToOne(() => require("./StickerPack").StickerPack, {
+		onDelete: "CASCADE",
+	})
+	pack: import("./StickerPack").StickerPack;
+
 	@Column({ nullable: true })
 	guild_id?: string;
 
@@ -36,6 +44,15 @@ export class Sticker extends BaseClass {
 	})
 	guild?: Guild;
 
+	@Column({ nullable: true })
+	user_id?: string;
+
+	@JoinColumn({ name: "user_id" })
+	@ManyToOne(() => User, {
+		onDelete: "CASCADE",
+	})
+	user?: User;
+
 	@Column({ type: "int" })
 	type: StickerType;
 
diff --git a/util/src/entities/StickerPack.ts b/util/src/entities/StickerPack.ts
new file mode 100644
index 00000000..b80fa9c7
--- /dev/null
+++ b/util/src/entities/StickerPack.ts
@@ -0,0 +1,31 @@
+import { Column, Entity, JoinColumn, OneToMany, OneToOne, RelationId } from "typeorm";
+import { Sticker } from ".";
+import { BaseClass } from "./BaseClass";
+
+@Entity("stickers")
+export class StickerPack extends BaseClass {
+	@Column()
+	name: string;
+
+	@Column({ nullable: true })
+	description?: string;
+
+	@Column({ nullable: true })
+	banner_asset_id?: string;
+
+	@OneToMany(() => Sticker, (sticker: Sticker) => sticker.pack_id, {
+		cascade: true,
+		orphanedRowAction: "delete",
+	})
+	stickers: Sticker[];
+
+	// sku_id: string
+
+	@Column({ nullable: true })
+	@RelationId((pack: StickerPack) => pack.cover_sticker)
+	cover_sticker_id?: string;
+
+	@OneToOne(() => Sticker, { nullable: true })
+	@JoinColumn()
+	cover_sticker?: Sticker;
+}