Skip to content

Commit d91d1e6

Browse files
authored
remove an unnecessary select query from updateRoom (#1389)
1 parent 6cf1f99 commit d91d1e6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

server/storage/room.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,12 @@ export async function updateRoom(room: Partial<RoomStatePersistable>): Promise<b
7676
throw new Error(`Cannot update room with no name`);
7777
}
7878
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-
}
8679
const options = roomToDbPartial(room);
8780
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;
9085
} catch (error) {
9186
log.error(`Failed to update room ${room.name} in storage: ${error}`);
9287
return false;

0 commit comments

Comments
 (0)