From 21931a20cbe2eb8609ea20dde9ded043c1adf71a Mon Sep 17 00:00:00 2001 From: Avraham Sakal Date: Sun, 21 Sep 2025 14:48:37 -0400 Subject: [PATCH] obsolete `facts` db layer --- server/trpc/facts.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/trpc/facts.ts b/server/trpc/facts.ts index 4baa691..8fa9283 100644 --- a/server/trpc/facts.ts +++ b/server/trpc/facts.ts @@ -51,8 +51,14 @@ Extract new facts from these messages.`; export const facts = router({ fetchByConversationId: publicProcedure .input((x) => x as { conversationId: string }) - .query(async ({ input: { conversationId }, ctx: { db } }) => { - return await db.facts.findByConversationId(conversationId); + .query(async ({ input: { conversationId }, ctx: { dbClient } }) => { + const rows = await dbClient + .selectFrom("facts") + .innerJoin("messages", "messages.id", "facts.sourceMessageId") + .selectAll("facts") + .where("conversationId", "=", conversationId) + .execute(); + return rows; }), deleteOne: publicProcedure .input( @@ -61,8 +67,8 @@ export const facts = router({ factId: string; } ) - .mutation(async ({ input: { factId }, ctx: { db } }) => { - await db.facts.delete(factId); + .mutation(async ({ input: { factId }, ctx: { dbClient } }) => { + await dbClient.deleteFrom("facts").where("id", "=", factId).execute(); return { ok: true }; }), update: publicProcedure @@ -73,8 +79,12 @@ export const facts = router({ content: string; } ) - .mutation(async ({ input: { factId, content }, ctx: { db } }) => { - await db.facts.update(factId, { content }); + .mutation(async ({ input: { factId, content }, ctx: { dbClient } }) => { + await dbClient + .updateTable("facts") + .set({ content }) + .where("id", "=", factId) + .execute(); return { ok: true }; }), extractFromNewMessages: publicProcedure