并非所有文档都包含请求字段的 Firebase 查询

Firebase query where not all the documents contain requested field

我在我的项目中使用 firebase。 现在我正在尝试从 firebase 获取文档,但面临以下问题。 基本上我有没有 hidden 字段的旧文件和有它的新文件。现在我想获取 hidden == fasle 所在的每个文档,而我正在尝试的是以下

getUserDocuments(): Observable<DocumentInterface[]> {
return this.db
  .collection<DocumentInterface>(CollectionNames.DOCUMENTS, (ref) =>
    ref.where('uid', '==', this.uid).orderBy('timeCreated', 'desc').where('hidden', '==', 'false')
  )
  .valueChanges();
}

我已经仔细阅读了文档,但不明白为什么我会收到空​​数组。如有任何帮助,我们将不胜感激!

我找到问题了。在 .where('hidden', '==', 'false') 中,我传递了值为 false 的字符串,但在数据库中它是布尔值,因此通过删除引号解决了问题:.where('hidden', '==', false).