obsolete `facts` db layer

master
Avraham Sakal 3 weeks ago
parent a41b97b442
commit 21931a20cb

@ -51,8 +51,14 @@ Extract new facts from these messages.`;
export const facts = router({ export const facts = router({
fetchByConversationId: publicProcedure fetchByConversationId: publicProcedure
.input((x) => x as { conversationId: string }) .input((x) => x as { conversationId: string })
.query(async ({ input: { conversationId }, ctx: { db } }) => { .query(async ({ input: { conversationId }, ctx: { dbClient } }) => {
return await db.facts.findByConversationId(conversationId); const rows = await dbClient
.selectFrom("facts")
.innerJoin("messages", "messages.id", "facts.sourceMessageId")
.selectAll("facts")
.where("conversationId", "=", conversationId)
.execute();
return rows;
}), }),
deleteOne: publicProcedure deleteOne: publicProcedure
.input( .input(
@ -61,8 +67,8 @@ export const facts = router({
factId: string; factId: string;
} }
) )
.mutation(async ({ input: { factId }, ctx: { db } }) => { .mutation(async ({ input: { factId }, ctx: { dbClient } }) => {
await db.facts.delete(factId); await dbClient.deleteFrom("facts").where("id", "=", factId).execute();
return { ok: true }; return { ok: true };
}), }),
update: publicProcedure update: publicProcedure
@ -73,8 +79,12 @@ export const facts = router({
content: string; content: string;
} }
) )
.mutation(async ({ input: { factId, content }, ctx: { db } }) => { .mutation(async ({ input: { factId, content }, ctx: { dbClient } }) => {
await db.facts.update(factId, { content }); await dbClient
.updateTable("facts")
.set({ content })
.where("id", "=", factId)
.execute();
return { ok: true }; return { ok: true };
}), }),
extractFromNewMessages: publicProcedure extractFromNewMessages: publicProcedure

Loading…
Cancel
Save