File tree 1 file changed +4
-9
lines changed
1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -76,17 +76,12 @@ export async function updateRoom(room: Partial<RoomStatePersistable>): Promise<b
76
76
throw new Error ( `Cannot update room with no name` ) ;
77
77
}
78
78
try {
79
- // TODO: optimize this to just do an update query, instead of a find and then update
80
- const dbroom = await DbRoomModel . findOne ( {
81
- where : buildFindRoomWhere ( room . name ) ,
82
- } ) ;
83
- if ( ! dbroom ) {
84
- return false ;
85
- }
86
79
const options = roomToDbPartial ( room ) ;
87
80
log . debug ( `updating room ${ room . name } in database ${ JSON . stringify ( options ) } ` ) ;
88
- await dbroom . update ( options ) ;
89
- return true ;
81
+ const result = await DbRoomModel . update ( options , {
82
+ where : buildFindRoomWhere ( room . name ) ,
83
+ } ) ;
84
+ return result [ 0 ] > 0 ;
90
85
} catch ( error ) {
91
86
log . error ( `Failed to update room ${ room . name } in storage: ${ error } ` ) ;
92
87
return false ;
You can’t perform that action at this time.
0 commit comments