misc: update db tables

This commit is contained in:
WJG 2024-01-28 14:52:32 +08:00
parent 9b79881c53
commit ef72a14ef6
No known key found for this signature in database
GPG Key ID: 258474EF8590014A
2 changed files with 52 additions and 28 deletions

View File

@ -14,63 +14,86 @@ model User {
id String @id @default(uuid())
name String
profile String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// 关联数据
rooms Room[] @relation("RoomMembers")
messages Message[]
memories Memory[]
shortTermMemories ShortTermMemory[]
longTermMemories LongTermMemory[]
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Room {
id String @id @default(uuid())
name String
description String
// 关联数据
members User[] @relation("RoomMembers")
messages Message[]
memories Memory[]
shortTermMemories ShortTermMemory[]
longTermMemories LongTermMemory[]
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Message {
id Int @id @default(autoincrement())
text String
// 消息发送者
// 关联数据
sender User @relation(fields: [senderId], references: [id])
senderId String
room Room @relation(fields: [roomId], references: [id])
roomId String
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
senderId String
}
model Memory {
id Int @id @default(autoincrement())
// 记忆拥有者
owner User @relation(fields: [ownerId], references: [id])
// 记忆类型:目前有 [ "message" ]
type String
// 记忆内容JSON字符串{ data: any }
content String
text String
// 关联数据
owner User? @relation(fields: [ownerId], references: [id]) // owner 为空时,即房间自己的公共记忆
ownerId String?
Room Room @relation(fields: [roomId], references: [id])
roomId String
shortTermMemories ShortTermMemory[]
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ownerId String
shortTermMemories ShortTermMemory[]
}
model ShortTermMemory {
id Int @id @default(autoincrement())
// 记忆拥有者
owner User @relation(fields: [ownerId], references: [id])
// 记忆最后更新的位置
cursor Memory @relation(fields: [cursorId], references: [id])
// 记忆内容:字符串
content String
text String
// 关联数据
cursor Memory @relation(fields: [cursorId], references: [id]) // 记忆最后更新的位置
cursorId Int
owner User? @relation(fields: [ownerId], references: [id]) // owner 为空时,即房间自己的公共记忆
ownerId String?
Room Room @relation(fields: [roomId], references: [id])
roomId String
longTermMemories LongTermMemory[]
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ownerId String
cursorId Int
longTermMemories LongTermMemory[]
}
model LongTermMemory {
id Int @id @default(autoincrement())
// 记忆拥有者
owner User @relation(fields: [ownerId], references: [id])
// 记忆最后更新的位置
text String
// 关联数据
cursor ShortTermMemory @relation(fields: [cursorId], references: [id])
// 记忆内容:字符串
content String
cursorId Int
owner User? @relation(fields: [ownerId], references: [id]) // owner 为空时,即房间自己的公共记忆
ownerId String?
room Room @relation(fields: [roomId], references: [id])
roomId String
// 时间日期
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ownerId String
cursorId Int
}

View File

@ -5,6 +5,7 @@ import { ShortTermMemory } from "./short-term";
import { LongTermMemory } from "./long-term";
// todo 在会话中,向会话的参与者分发消息(记忆),公共记忆,个人记忆
// todo 通知会话参与者
export class UserMemory {
private user: User;