Firestore 查询 where(documentId(), 'in', array) 给我一个错误

jus*_*tin 11 node.js firebase google-cloud-firestore

我正在尝试对与 id 数组(自定义文档 id)匹配的集合中的文档运行查询,但出现此错误:

错误:FieldPath.documentId() 的对应值必须是字符串或 DocumentReference。

这是我的代码:

const admin = require('firebase-admin');
const db = admin.firestore();

let ids = ['12_5', '12_6'];
db.collection('myCollection').where(admin.firestore.FieldPath.documentId(), 'in', ids).get()
Run Code Online (Sandbox Code Playgroud)

这些文档存在于 Firestore 中,我使用自定义文档 ID 创建了它们,以便能够轻松检索我需要的确切文档。 我在 Firestore 中的文档

关于如何解决此错误的任何想法?

小智 0

删除 package-lock.json 锁定文件,然后安装最新的 @google-cloud/firestore