【发布时间】:2021-07-30 00:01:16
【问题描述】:
此功能在 Cloud Functions 中,我想知道如何仅获取特定文档的一个字段,而不仅仅是获取所有文档数据。我的代码:
export const onNewOrder = functions.firestore.document("/orders/{orderId}").onCreate(async (snapshot, context) => {
const orderId = context.params.orderId;
// Where do I specify the data from which field I want to fetch?
const snap = await admin.firestore().collection("orders").doc(orderId).get();
console.log(snap.data());
});
我在哪里指定要从哪个字段获取数据?
【问题讨论】:
标签: typescript firebase google-cloud-firestore