I need a database structure that consists of nested maps such as the following example:
The upper map structure is: (key: "referrals", value: (key: userId, value: aBooleanValue))
So I used the following code to accomplish the result above:
let userId = ...
let aBooleanValue = ...
database.(...).setData(["referrals": [userId: aBooleanValue]])
But the code above causes an array inside of a map like the figure below instead of a nested map:
Any ideas how I could get rid of the array here?
EDIT: It's my bad. I was modifying the database as an array in another part of the app. So there is no bug here. Sorry.
CodePudding user response:
If you want referrals to be a key in the map then you must first declare the map, which you never do. The above code, btw, gave me a map, not an array. But the map was named referrals and its only key was userId. Regardless, to make referrals a key itself, define the parent map:
Firestore.firestore().document("test/test").setData([
"containerMap": [
"referrals": ["user1": true, "user2": true],
"contacts": ["user5": true, "user7": true]
]
])


