participantUIDs
is a map in a Firestore document:
I retrieve this document from Firestore (this part is successful) and try to iterate over the map to put its keys as strings into an array. Unfortunately, it doesn't work. The console is saying that I can't use forEach
(and neither a normal for-loop) on participantUIDsMap
. What's wrong with my Map?
const chatDoc = await admin.firestore().doc(`group_chats/${context.params.chatId}`).get()
// the document is retrieved successfully, I checked it with another field.
const participantUIDsMap: Map<string, boolean> = chatDoc.get('participantUIDs')
const participantUIDsArray: string[] = []
participantUIDsMap.forEach((value, key) => {
if (value === true && key != senderUid) {
participantUIDsArray.push(key)
}
})