[英]Post data in array cloud firestore
Am working on an array to store multiple map location in an array using geopoint
. 我正在处理一个数组,以使用
geopoint
在数组中存储多个地图位置。 Have a location:geopoint
that accepts latitude and longitude, which are stored in an array. 有一个接受纬度和经度的
location:geopoint
,它们存储在数组中。 Cloud firestore only has set
for creating new document update
update existing document and add
which have tried to add new geopoint to the array but it doesn't work. Cloud Firestore仅
set
用于创建新文档的update
更新现有文档并add
已尝试将新的Geopoint添加到阵列中的文档,但这是行不通的。 How can I add new location while maintaining the previous data? 如何在维持先前数据的同时添加新位置?
Cloud Firestore doesn't currently have an "append an element to an array" kind of operation. Cloud Firestore当前没有“将元素添加到数组”类型的操作。 For now, your best options are to either:
目前,您最好的选择是:
Your implementation might depend on how many of these different geopoints you're planning on creating, and how you plan on querying them. 您的实现可能取决于您计划创建多少个不同的地理位置,以及计划如何查询它们。 If you're creating only a handful and want to get all of them back when you're grabbing the associated document, I'd go with one of the first two options.
如果您只创建少数几个文件,并且想在获取关联文档时将所有文件都找回,那么我将使用前两个选项之一。 If you're planning on creating lots of geopoints and, say, want to only grab the 3 most recent, I'd go with the third option.
如果您打算创建大量的地理点,并且想只获取最近的三个,那么我会选择第三个选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.