【问题标题】:Firebase .where('smth','==',true) query doesn't work correctlyFirebase .where('smth','==',true) 查询无法正常工作
【发布时间】:2019-09-07 19:01:50
【问题描述】:

使用多个查询,如 .where("status", "==", true) 我什么也得不到,我的“快照”是空的 screenshot 1,但它必须返回所有文档,其中“状态”不为空。

var firstLoad = () => {

var first = $scope.colRef
    .where("status", "==", true)
    .where("manager", "==", true)
    .orderBy("last_activity_date", 'desc')
    .limit(25);

first.get()
    .then(firstSnapshot => {
        console.log(firstSnapshot);
    })
    .catch(error => {
        console.log(error);
    });
}
firstLoad();

然后,我更改查询,现在它就像.where("status", "==", "Потенциальный"),我得到正确答案screenshot 2。

我想知道,如何使用.where 获取所有这些“状态”不为空的文档?

【问题讨论】:

  • @ponury-kostek Firestore 目前没有不等式查询。

标签: javascript angularjs firebase google-cloud-firestore


【解决方案1】:

Firestore 无法在查询中表示“非空”。您可以检查是否相等(如您所见)。你至少有可能的选择。在文档中存储另一个布尔字段,并将其设置为 true 表示“非空状态”,设置为 false 表示“空状态”。

【讨论】:

  • 你能用类似于.orderBy('status').startAt("") 的东西在 RTDB 中工作吗?并不是说它在这种情况下有帮助。
  • 或许可以查询 > ""。
猜你喜欢
  • 1970-01-01
  • 2016-09-07
  • 1970-01-01
  • 2017-01-03
  • 1970-01-01
  • 2016-06-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-29
相关资源
最近更新 更多