Skip to content

Commit 200bd7f

Browse files
patch prisma query expansion on threads
1 parent b1a2fa6 commit 200bd7f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

server/models/workspaceThread.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ const WorkspaceThread = {
2525
update: async function (prevThread = null, data = {}) {
2626
if (!prevThread) throw new Error("No thread id provided for update");
2727

28-
const validKeys = Object.keys(data).filter((key) =>
29-
this.writable.includes(key)
30-
);
31-
if (validKeys.length === 0)
28+
const validData = {};
29+
Object.entries(data).forEach(([key, value]) => {
30+
if (!this.writable.includes(key)) return;
31+
validData[key] = value;
32+
});
33+
34+
if (Object.keys(validData).length === 0)
3235
return { thread: prevThread, message: "No valid fields to update!" };
3336

3437
try {
3538
const thread = await prisma.workspace_threads.update({
3639
where: { id: prevThread.id },
37-
data,
40+
data: validData,
3841
});
3942
return { thread, message: null };
4043
} catch (error) {

0 commit comments

Comments
 (0)