Javascript 在Firebase函数中按documentId查询
当我使用documentId作为字段路径从Firebase Firestore查询数据时,在网页(javascript)和Firebase函数(Node.js)上运行脚本时,我会得到不同的行为 此javascript为我提供了完美的结果:Javascript 在Firebase函数中按documentId查询,javascript,firebase,google-cloud-functions,google-cloud-firestore,firebase-admin,Javascript,Firebase,Google Cloud Functions,Google Cloud Firestore,Firebase Admin,当我使用documentId作为字段路径从Firebase Firestore查询数据时,在网页(javascript)和Firebase函数(Node.js)上运行脚本时,我会得到不同的行为 此javascript为我提供了完美的结果: firebase.firestore().collection('test') .where(firebase.firestore.FieldPath.documentId(), '<=', 'ccc') .get() .then(snaps
firebase.firestore().collection('test')
.where(firebase.firestore.FieldPath.documentId(), '<=', 'ccc')
.get()
.then(snapshots => { /* results are here */ });
firebase.firestore().collection('test'))
.where(firebase.firestore.FieldPath.documentId(),”这确实是节点SDK中的一个功能遗漏,我们将在下一版本中解决
您现在可以通过直接传递DocumentReference来解决此问题:
const coll = admin.firestore().collection('test')
coll
.where(admin.firestore.FieldPath.documentId(), '<=', coll.doc('ccc'))
.get()
.then(snapshots => { /* ... */ });
const coll=admin.firestore().collection('test'))
科尔
.where(admin.firestore.FieldPath.documentId(),“这在我看来像个bug。我已经在firestore团队内部提交了一份bug报告。@google cloud/firestore v0.12.0包含了此问题的修复程序。很抱歉更新此线程,但我无法使用documentId FieldPath实现where。请始终返回“FieldPath.documentId()的对应值必须是字符串或DocumentReference”错误:/带有字符串或文档(在
中使用带有数组的),我仍在与firestore团队争论这一点。最终结果是FieldPath.documentId在documentId上不匹配,但在refPath上匹配(如果传递了文档引用,它会自动获取)。如果您有文档引用,为什么要使用collectionGroup?
const coll = admin.firestore().collection('test')
coll
.where(admin.firestore.FieldPath.documentId(), '<=', coll.doc('ccc'))
.get()
.then(snapshots => { /* ... */ });