【发布时间】:2021-02-10 10:14:03
【问题描述】:
在电子商务颤振应用程序项目中,我使用我的项目集合的 shortInfo 字段作为每个产品的唯一 ID。当按下添加到购物车时,它会将shortInfo 保存到我的users 集合中一个名为userCartList 的数组字段中,我正在使用WhereIn 来查询这个数组,但是当我有超过10 个产品时,我的应用程序崩溃了。我在这里做错了什么?
这是我的 Firestore 结构:
这是我正在查询的一个 sn-p:
StreamBuilder<QuerySnapshot>(
stream: EcommerceApp.firestore
.collection("items")
.where("shortInfo", whereIn: EcommerceApp.sharedPreferences.getStringList(EcommerceApp.userCartList))
.snapshots()
)
【问题讨论】:
-
你能提供导致错误的代码的sn-ps吗?
-
StreamBuilder
( //TODO: 修复问题流:EcommerceApp.firestore .collection("items") .where("shortInfo", whereIn: EcommerceApp.sharedPreferences .getStringList(EcommerceApp. userCartList)) .snapshots(), -
此代码给出了所需的结果,但是当根据 firebase 规则添加超过 10 个产品时,此查询方法不允许超过 10 个,这就是导致错误的原因。用户购物车列表是保存在我从 firebase 检索的共享首选项中的列表
标签: firebase flutter google-cloud-firestore