首页 > 解决方案 > Firebase 管理员查询:collection where documentId() IN Array of ids

问题描述

此查询适用于 Web Firebase SDK:

firestore.collection("recipes").where(firebase.firestore.FieldValue.documentId(), 'in', ['recipe12','recipe17']).get()

但是在我的带有“firebase-admin”的云功能中,我收到了这个错误:

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

标签: node.jsfirebasegoogle-cloud-firestoregoogle-cloud-functionsfirebase-admin

解决方案


firebase.firestore.FieldPath.documentId()在 Web 和 Admin SDK 中都有。

网站:https ://firebase.google.com/docs/reference/js/firebase.firestore.FieldPath.html#documentid

阿迪明:https ://googleapis.dev/nodejs/firestore/latest/FieldPath.html#.documentId

FieldValue.documentId()应该是undefined


推荐阅读