扩展到我的问题Firestore - How to model and query relation of 2 collections - IOT use case
我现在看到了一个关于这个的视频,这建议使用文档ID. https://www.youtube.com/watch?v=jm66TSlVtcc跳到6:07来建立关系模型。
我想知道这种方法在这种情况下是否有效(修改我最初问题中的示例,以适应youtube上关于防火墙关系的建议:
例句:我有两个不同的收藏追踪和地点。
跟踪<--收集
1. document(xyz123)
venueId = "abcd1234"
timestamp = 10/09/2019 10:00
2. document(xyz567)
venueId = "efgh3456"
timestamp = 10/09/2019 11:00地点<-收藏
1. document(abcd1234) <-- notice i shift the device_unique_identifier here instead
name = "room A"
// device_unique_identifier = "abcd1234" <-- this is unique name
2. document(efgh3456) <-- notice i shift the device_unique_identifier here instead
name = "room B"
// device_unique_identifier = "efgh3456" <-- this is unique name主要问题:我想查询文件xyz123,并得到在这一行的地点名称。因此,产出如下:
document(xyz123)
device_unique_identifier = "abcd1234"
timestamp = 10/09/2019 10:00
venue.name = "room A"关于另一个可能的额外问题,当插入跟踪数据时,是否可以在不需要查询地点数据的情况下自动将地点数据作为对象插入到防火墙后端?
发布于 2019-09-21 02:57:22
这在Firebase中是不可能的。在Firebase中没有加入的概念。如果数据存在于两个独立的文档中,则需要重新考虑如何存储数据(这样就可以同时调用数据,等等)。或进行所有需要的调用,以实现最终期望的输出。
您可以像存储数据一样存储数据,但不能查询一个文档以获得当前结构的输出。
https://stackoverflow.com/questions/58036882
复制相似问题