相关疑难解决方法(0)

如何在 Flutter Firestore 中使用多个 where 子句

我想从 firestore 列出一种数据。每个文档都包含一个“状态”字段。我需要从列表中提取 3 种不同类型的状态。我如何在 dart 中为我的颤振项目做到这一点?

以下代码,它对我不起作用。

getStream() {
  var snapshots = firestore.collection("booking")
  .where("userId", isEqualTo: uid)
  .where("status", isEqualTo: "confirmed")
  .where("status", isEqualTo: "unconfirmed")
  .where("status", isEqualTo: "unconfirmed quotation")
  .snapshots();
  return snapshots;
}
Run Code Online (Sandbox Code Playgroud)

where firebase flutter google-cloud-firestore

6
推荐指数
0
解决办法
4556
查看次数

多个Firestore查询,单个承诺/回调

我知道Firestore不支持查询的逻辑OR.我的想法是创建多个查询并在客户端合并结果.我正在开发一个新闻应用程序,我正在尝试获取包含用户兴趣标签的所有文章(例如技术,音乐等)普通用户有20个标签,因此我将提出20个不同的请求.

有没有人有链接多个请求的经验,并在所有结果到来时返回一个独特的承诺.

我正在使用js sdk

我的数据结构:

文章(收藏)

-article (document)
--id: 10
--time: 1502144665
--title: "test title"
--text: "test text"
--tags(obj) 
---technology: 1502144665,
---politics: 1502144665,
---sports: 1502144665
Run Code Online (Sandbox Code Playgroud)

所以我需要创建多个db请求,如下所示.

user.tags = ["technology","politics","sports","architecture","business"];

for (var i = 0; i < user.tags.length; i++) {
  db.collection('articles').where(user.tags[i], '>', 0).orderBy(user.tags[i]))
    .get()
    .then(() => {
        // ... push to article array
  });)
}
Run Code Online (Sandbox Code Playgroud)

我试图弄清楚如何在每个请求完成时创建一个promise/callback.

firebase google-cloud-firestore

1
推荐指数
2
解决办法
5022
查看次数

标签 统计

firebase ×2

google-cloud-firestore ×2

flutter ×1

where ×1