【问题标题】:how to fetch all docouments with an ID that doesnt exist in the given array? (Cloud Firestore)如何获取给定数组中不存在 ID 的所有文档? (云防火墙)
【发布时间】:2021-01-25 08:17:13
【问题描述】:

我有一个 ID 数组。现在,我想获取该数组中不存在的所有文档。

假设let array = ["id1", "id2", "id3];

Firestore 中的文档 ID:“id1”、“id2”、“id3”、“id4”、“id5”

所以基本上我只需要获取带有“id4”和“id5”的文档;

我想过使用这个,但我不确定具体如何:

const westCoastCities = citiesRef.where('regions', 'array-contains', 'west_coast').get();

我是 Firebase 的新手,所以请耐心等待。

【问题讨论】:

    标签: javascript firebase google-cloud-firestore


    【解决方案1】:

    这应该可以工作

    idsRef.where('ids', 'not-in', ["id1", "id2", "id3]);
    
    

    你应该总是先检查他们的文档https://firebase.google.com/docs/firestore/query-data/queries#not-in

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 2019-06-01
      • 2020-04-19
      • 2021-05-05
      • 2018-03-30
      • 2018-02-01
      • 1970-01-01
      • 2021-02-16
      • 2017-03-25
      相关资源
      最近更新 更多