问题
I need to add array in an array-like I am creating you can see in the image I need to add 2 arrays in member. I need to save uid+name. but there is no option of the array just string, number, boolean etc.
回答1:
How can we create an array in array in Firestore?
You cannot. There is no way you can add an array within another array. The array is not a supported data type when it comes to array values. You can add an array that can contain strings, numbers, booleans, maps, timestamps, geopoints, references or even null but not arrays. What you are looking for is a 2D array, which is currently not allowed. You cannot create an array of arrays. The only viable option that you have is to use objects (maps). Such a document should look like this:
autoId
|
--- myArray
|
--- 0
| |
| --- propertyOne: "value"
| |
| --- propertyTwo: "value"
|
--- 1
|
--- propertyOne: "value"
|
--- propertyTwo: "value"
So you'll end up having an array of maps. To get that data back, simply get the document and iterate through that list of maps.
来源:https://stackoverflow.com/questions/59067832/how-can-we-create-an-array-in-array-in-firestore