首页 文章

Firestore - 如何使用空 Map 字段获取所有文档?

提问于
浏览
0

我有一个名为“posts”的Firebase Firestore集合,其结构如下:

{
    "title": "My blog title",
    "categories": {
        "general": true,
        "sample": true
    }
}

我可以查询类似"general"的所有博客帖子,如下所示: db.collection('posts').where('categories.general', '==', true).get().then() 但是,我似乎无法找到一种方法来获取"categories" Map 为空的所有文档 .

我想查询"posts"集合中 "categories": {} 的所有文档 . 我试过 db.collection('posts').where('categories', '==', {}).get().then() 但是没用 . 我该如何获取这些数据?

1 回答

  • 1

    你正在尝试的是不可能的 . Firestore索引的工作方式是文档中存在字段,而不是缺少字段 . 您只能期望能够查询实际存在的内容 .

相关问题