(data)
| 83 | |
| 84 | // Insert messages into the example database for long term storage |
| 85 | async function addMessageToDb(data) { |
| 86 | const room = messageDb.find(messages => messages.room === data.room); |
| 87 | if (room) { |
| 88 | // Update room in database |
| 89 | Object.assign(room, data); |
| 90 | } else { |
| 91 | // Create new room in database |
| 92 | messageDb.push(data); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Query the example database for messages for a specific room |
| 97 | function getRoomFromDatabase(roomName) { |