【问题标题】:Is there any way to get data about a query from a query object in Firebase Firestore libraries?有什么方法可以从 Firebase Firestore 库中的查询对象获取有关查询的数据?
【发布时间】:2021-08-27 18:06:31
【问题描述】:

标题并没有很好地解释这一点。

我的意思是:例如,我构建了一个这样的查询(取自 firebase 网站):

// Create a reference to the cities collection
CollectionReference citiesRef = db.collection("cities");

// Create a query against the collection.
Query query = citiesRef.whereEqualTo("state", "CA");

有没有办法从查询中获取我上面提供的查询信息,例如它正在寻找“状态”等于“CA”的项目。基本上,我正在尝试获取查询的字符串表示形式,我可以在以后的代码中使用它来查看查询正在搜索的内容。就像是: query.getInfo() 将返回 FIREBASE QUERY ON /cities/ WHERE state EQUALSTO CA 甚至有机会选择单个部分,例如将返回 state == CA 或类似内容的“whereEqualTo”

【问题讨论】:

    标签: java android firebase google-cloud-firestore


    【解决方案1】:

    不幸的是,Firestore Query 类中没有 getInfo() 方法。如果您需要知道您的用户在搜索什么,那么您应该为此创建自己的机制。您拥有的最佳选择是将这些搜索的字符串表示形式存储在 Cloud FirestoreRealtime Database 中。

    【讨论】:

      猜你喜欢
      • 2021-04-09
      • 1970-01-01
      • 1970-01-01
      • 2021-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 2013-08-30
      相关资源
      最近更新 更多