Py学习  »  NoSql

为NoSQL和Flutter复制SQL联接的FireStore

Jake Anderson • 6 年前 • 1035 次点击  

我意识到,在复制与NoSQL文档数据库(如FireStore)的连接方面存在许多问题,但是我无法找到一个使用FireStore的dart/flutter的彻底解决方案。

我做过一些研究,我觉得在下面的例子中,我会寻找“多对多”的关系(如果这是错误的,请纠正我),因为将来可能需要查看所有的配置文件以及所有的连接。

在FireBase中,我有两个根级别的集合(配置文件和连接):

profile
    > documentKey(Auto Generated)
         > name = "John Smith"
         > uid = "xyc4567"

    > documentKey(Auto Generated)
         > name = "Jane Doe"
         > uid = "abc1234"

    > documentKey(Auto Generated)
         > name = "Kate Dee"
         > uid = "efg8910"



connection
    > documentKey(Auto Generated)
         > type = "friend"
         > profileuid = "abc1234"
         > uid = "xyc4567"

    > documentKey(Auto Generated)
         > type = "family"
         > profileuid = "abc1234"
         > uid = "efg8910"

在本例中,当用户john smith(uid:xyc4567)连接到Jane doe(uid:abc1234)和kate dee(uid:efg8910)时,已假设为该用户创建了“连接”文档。

下面是我要复制的关系SQL,以显示John Smith所连接的配置文件列表:

Select * FROM profile, connection 
WHERE profile.uid = connection.profileuid 
AND profile.uid = "xyc4567"

在flutter my flutter应用程序中,我有一个FireStore查询起点:

stream: Firestore.instance.collection('profile')
.where('uid', isEqualTo: "xyc4567").snapshots(),

显然,它只从一个集合返回。如何加入多对多关系中的集合?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/30507
 
1035 次点击  
文章 [ 2 ]  |  最新文章 6 年前