({ conversationId })
| 47 | |
| 48 | export const prismaConversationStore: ConversationStore = { |
| 49 | async load({ conversationId }) { |
| 50 | const conv = await db.conversation.findUnique({ |
| 51 | where: { id: conversationId }, |
| 52 | include: { |
| 53 | messages: { orderBy: { createdAt: 'asc' } }, |
| 54 | }, |
| 55 | }); |
| 56 | if (!conv) return null; |
| 57 | |
| 58 | return { |
| 59 | items: conv.messages.map((m) => m.parts as unknown as ConversationItem), |
| 60 | cursor: conv.updatedAt.getTime(), |
| 61 | }; |
| 62 | }, |
| 63 | |
| 64 | async save({ conversationId, items }) { |
| 65 | const owner = chatRunContext.getStore(); |