I am currently developing a Firebase Cloud Functions application using TypeScript that is designed to save an instance of Map() to Cloud Firestore. The map consists of user IDs as keys and objects with 2 simple attributes as values. Due to the dynamic nature of the keys, I cannot determine them beforehand.
When attempting to save the map object directly, the following error occurs: "Value for argument 'data' is not a valid Firestore document. Input is not a plain JavaScript object (found in field 'member_details')"
An alternative approach was considered by initializing an empty object {} instead of using a Map(), as shown below:
let memberDetailsMap = {};
this.memberDetails.forEach(md => {
let payload = {
"name": md.name,
"age": md.age,
}
memberDetailsMap[md.uid] = payload; // <- !!!!!!!! ERROR
})
This attempted solution prevented me from compiling TypeScript to JavaScript, showing the error message:
"Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'."
Another method I tried involved using JSON.stringify(memberDetailsMap), which unfortunately resulted in an empty object.
I am currently stuck on resolving this issue. Do you have any hints or solutions to offer?
Thank you for your assistance!