feat: add join columns
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
BaseEntity,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { Conversation } from './conversation.entity';
|
||||
import { MessageRole } from '../enums/message-role.enum';
|
||||
@@ -14,9 +15,17 @@ export class Message extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id!: number;
|
||||
|
||||
@Column({
|
||||
type: 'int',
|
||||
name: 'conversationId',
|
||||
nullable: false,
|
||||
})
|
||||
conversationId!: number;
|
||||
|
||||
@ManyToOne(() => Conversation, (conversation) => conversation.messages, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'conversationId' })
|
||||
conversation!: Conversation;
|
||||
|
||||
@Column({
|
||||
|
||||
Reference in New Issue
Block a user