Mediasoup saving rooms in MongoDB

Currently I am saving all the active rooms in memory. Is it possible to save these room object in the MongoDB? As room object keeps on changing regularly based on whoever joined the room, Shall I update the room object in DB regularly. Could you please tell me what shall I do in order to restrict RAM usage? Please check the below code:-

function getOrCreateRoom({ roomId, router }) {
  const room = rooms.get(roomId);
  // If the Room does not exist create a new one.
  if (!room) {
    return new Promise(resolve => {
      const room = new ConfRoom(router, roomId);
      rooms.set(roomId, room);
      let roomModel = new RoomModel({
        roomMap: room,
        roomMapId: roomId
      }), data){
        } else {

      room.on("close", () => {
        if(room._protooRoom.peers.length === 1)
        } else {
          console.warn(`Room has ${room._protooRoom.peers.length} in it`);
  return room;

You should not store complex objects (such as a mediasoup Router) in a DB. It’s not a plain object. Just store it’s associated data and update it when required. This is not related to mediasoup.