feat: add conversations endpoint (#141)

This commit is contained in:
2026-06-17 23:01:08 +01:00
committed by GitHub
parent e11051b04b
commit e1c58cdf28
4 changed files with 164 additions and 0 deletions

View File

@@ -101,6 +101,14 @@ export function conversations(db: Database, userId: string) {
return insertConversation(db, userId)
},
async listConversations(): Promise<ConversationRow[]> {
return db
.select()
.from(conversationsTable)
.where(eq(conversationsTable.userId, userId))
.orderBy(desc(conversationsTable.updatedAt), desc(conversationsTable.createdAt))
},
async getOrCreateConversation(): Promise<ConversationRow> {
return db.transaction(async (tx) => {
await requireUserForUpdate(tx, userId)