MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / addMessageToDb

Function addMessageToDb

run/websockets/redis.js:85–94  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

83
84// Insert messages into the example database for long term storage
85async 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
97function getRoomFromDatabase(roomName) {

Callers 1

addMessageToCacheFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected