首页 > 解决方案 > 使用 != 和 not-in 查询会在 firestore 中使用 Query.where 引发错误

问题描述

我尝试使用!=not-in作为参数,如此Query.where所述:

    db.collection("users")
      .where(firebase.firestore.FieldPath.documentId(), "!=", curUser.uid)
      .get()
      .then((snapshot) => {
         ...
      });

但我收到以下错误:

提供给函数 Query.where() 的第二个参数的无效值“!=”。可接受的值:<、<=、==、>=、>、array-contains、in、array-contains-any

我什至在一个普通的非文档 id 字段上尝试了这个,它给出了同样的错误。

我正在使用节点包firebase版本 7.9.0。

标签: javascriptfirebasegoogle-cloud-firestore

解决方案


您需要使用最新版本才能使用不相等查询:

npm install firebase@8.0.0 --save

!=发布版本7.21.0

https://firebase.google.com/support/release-notes/js#version_7210_-_september_17_2020


推荐阅读