I have a dynamic list/array of users that I want to add to my firebase db. I looked at Setting arrays in Firebase using Firebase console which suggested to store arrays like the following data structure:
uid: {
attendees: {
"Bill Gates": true,
"Larry Page": true,
"James Tamplin": true
}
}
However, creating a dictionary and adding them one by one to the user field is inefficient:
let dict: Dictionary<String, Any> = [
"location": "",
"attendees": {
"Bill Gates": true,
"Larry Page": true,
"James Tamplin": true,
....
}
]
If I have 100 attendees, it's inefficient to add them one by one to my dictionary and set each of its value to true. How can I add my data more compactly? When I get back the user dictionary, how can I retrieve each key in attendees?