mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-14 02:20:12 +01:00
patch prisma query expansion on threads
This commit is contained in:
parent
b1a2fa6385
commit
200bd7f061
@ -25,16 +25,19 @@ const WorkspaceThread = {
|
|||||||
update: async function (prevThread = null, data = {}) {
|
update: async function (prevThread = null, data = {}) {
|
||||||
if (!prevThread) throw new Error("No thread id provided for update");
|
if (!prevThread) throw new Error("No thread id provided for update");
|
||||||
|
|
||||||
const validKeys = Object.keys(data).filter((key) =>
|
const validData = {};
|
||||||
this.writable.includes(key)
|
Object.entries(data).forEach(([key, value]) => {
|
||||||
);
|
if (!this.writable.includes(key)) return;
|
||||||
if (validKeys.length === 0)
|
validData[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Object.keys(validData).length === 0)
|
||||||
return { thread: prevThread, message: "No valid fields to update!" };
|
return { thread: prevThread, message: "No valid fields to update!" };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const thread = await prisma.workspace_threads.update({
|
const thread = await prisma.workspace_threads.update({
|
||||||
where: { id: prevThread.id },
|
where: { id: prevThread.id },
|
||||||
data,
|
data: validData,
|
||||||
});
|
});
|
||||||
return { thread, message: null };
|
return { thread, message: null };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user