File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -25,16 +25,19 @@ const WorkspaceThread = {
25
25
update : async function ( prevThread = null , data = { } ) {
26
26
if ( ! prevThread ) throw new Error ( "No thread id provided for update" ) ;
27
27
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 )
32
35
return { thread : prevThread , message : "No valid fields to update!" } ;
33
36
34
37
try {
35
38
const thread = await prisma . workspace_threads . update ( {
36
39
where : { id : prevThread . id } ,
37
- data,
40
+ data : validData ,
38
41
} ) ;
39
42
return { thread, message : null } ;
40
43
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments