summary refs log tree commit diff
path: root/util/src/entities/ReadState.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 20:48:09 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-26 20:48:09 +0200
commitdb3f5c0d1b5556e16c37704467b3599a6230be02 (patch)
treee74df1466e66900a284c65e270d56040d0dfde7e /util/src/entities/ReadState.ts
parent:bug: fix unit tests (diff)
downloadserver-db3f5c0d1b5556e16c37704467b3599a6230be02.tar.xz
:sparkles: use RelationId
Diffstat (limited to 'util/src/entities/ReadState.ts')
-rw-r--r--util/src/entities/ReadState.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/util/src/entities/ReadState.ts b/util/src/entities/ReadState.ts
index 7c56b6c6..0310cb5f 100644
--- a/util/src/entities/ReadState.ts
+++ b/util/src/entities/ReadState.ts
@@ -1,4 +1,4 @@
-import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
+import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { BaseClass } from "./BaseClass";
 import { Channel } from "./Channel";
 import { Message } from "./Message";
@@ -6,20 +6,23 @@ import { User } from "./User";
 
 @Entity("read_states")
 export class ReadState extends BaseClass {
-	@Column()
+	@RelationId((read_state: ReadState) => read_state.channel)
 	channel_id: string;
 
 	@JoinColumn({ name: "channel_id" })
 	@ManyToOne(() => Channel, (channel: Channel) => channel.id)
 	channel: Channel;
 
-	@Column()
+	@RelationId((read_state: ReadState) => read_state.user)
 	user_id: string;
 
 	@JoinColumn({ name: "user_id" })
 	@ManyToOne(() => User, (user: User) => user.id)
 	user: User;
 
+	@RelationId((read_state: ReadState) => read_state.last_message)
+	last_message_id: string;
+
 	@JoinColumn({ name: "last_message_id" })
 	@ManyToOne(() => Message, (message: Message) => message.id)
 	last_message?: Message;