obsolete facts db layer

This commit is contained in:
Avraham Sakal
2025-09-21 14:48:37 -04:00
parent a41b97b442
commit 21931a20cb
+16 -6
View File
@@ -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