如何在云功能中从firestore获取文档
我已经尝试了许多方法,例如
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
const docRef = db.collection("users").doc(dynamicDocID).get()
const docRef = db.collection("users").doc(dynamicDocID)
许多其他方法,但始终未定义或似乎永远无法解决的承诺
似乎无法找到适当的文档(如果有的话)
I've tried many methods such as
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
const docRef = db.collection("users").doc(dynamicDocID).get()
const docRef = db.collection("users").doc(dynamicDocID)
as well as many other and keep getting undefined or a promise that never seems to be resolved
Cant seem to find proper docs on this if anything
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于 Firebase 的 Cloud Functions 是用 Node.js 编写的,因此请查看 Firestore 文档。
基于此:
或者如果您不能使用
await
:Since Cloud Functions for Firebase are written in Node.js, have a look at the Node.js examples in the Firestore documentation.
Based on that:
Or if you can't use
await
: