diff options
Diffstat (limited to 'util/src/entities/ReadState.ts')
-rw-r--r-- | util/src/entities/ReadState.ts | 9 |
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; |