feat: add conversation module
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Conversation } from './conversation.entity';
|
||||
import { MessageRole } from '../enums/message-role.enum';
|
||||
|
||||
@Entity()
|
||||
export class Message {
|
||||
@PrimaryGeneratedColumn()
|
||||
id!: number;
|
||||
|
||||
@ManyToOne(() => Conversation, (conversation) => conversation.messages, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
conversation!: Conversation;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: MessageRole,
|
||||
nullable: false,
|
||||
})
|
||||
role!: MessageRole;
|
||||
|
||||
@Column({ type: 'text' })
|
||||
content!: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user