mirror of
https://github.com/kennethnym/freya
synced 2026-07-05 07:21:15 +01:00
feat: add conversations endpoint (#141)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user