问题描述
我的意思是如何在Firestore中获得阵列?
I mean how can I get an array in Firestore?
例如,当我有一个简单字段时,用[(ngModel)] ="proyecto.titulo"
输入它,但是在这种情况下,如何在数组中输入数据?
For example, when I have a simple field I enter it with [(ngModel)] ="proyecto.titulo"
but in this case, how do I enter the data in an array?
推荐答案
如果要保存数组,可以编写db.doc("documentName.etiquetas").set(["tag1", "tag2", "tag2"])
If you want to save an array you can write db.doc("documentName.etiquetas").set(["tag1", "tag2", "tag2"])
这将最终成为您想要的结构.
this will end up as the structure you want.
但是,最好将其另存为索引为0,1,2,...
的地图.因为在这种情况下,您可以直接引用和更新元素.例如. db.doc("documentName.etiquetas.0").set("new tag1")
However, it's better to save it as a map with index 0,1,2,...
. Because in that case you can directly reference and update the element. Eg. db.doc("documentName.etiquetas.0").set("new tag1")
这篇关于添加阵列Firestore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!