I am trying to set data in a Firestore document from an object of a TypeScript class -
class Quest {
id: number = Date.now();
index: number = 0;
quest: string[];
options = new Map<string, string[]>();
goals: string[];
}
To convert the class to JSON -
questDocRef.set(JSON.parse(JSON.stringify(quest)));
This sets all the fields in the quest doc except the Map field named options.
What would be a good way to achieve this?
Map
,Set
,WeakMap
, andWeakSet
. It supports two types of aggregations: objects and arrays.