【发布时间】:2020-08-07 12:13:06
【问题描述】:
我查看了类似问题的类似答案,但这些答案并不特别适用。 我在 js 的 firestore onCreate 函数中寻找简单的文档父自动 ID?
firestore 函数日志读取函数返回 undefined for documentiD 你如何引用documentID?
Firestore 日志结果:sendMailtransaction 函数返回未定义、预期的 Promise 或值
//Send the transaction email
exports.sendMailtransaction = functions.firestore
.document('Companys/{companyid}/Transaction/{transactionid}')
.onCreate((snap, context) => {
const transDocument = functions.firestore.document('Companys/{companyid}/Transaction/{transactionid}');
const documentiD = transDocument.documentID;
const mailOptions = {
from: 'L App<report@sample.com>', // You can write any mail Address you want this doesn't effect anything,
to: snap.data().companyemailcf, // This mail address should be filled with any mail you want to read it,
bcc: 'admin@l.com',
subject: 'L Record, New Tranaction ',
html: `<h1>Confirmed Transaction</h1>
<p>
<b>Ref: </b>${documentiD}<br>
<b>Datetime: </b>${snap.data().datetime}<br>
<b>User: </b>${snap.data().user}<br>
<b>Vehicle: </b>${snap.data().vehicle}<br>
</p>`
};
}
【问题讨论】:
标签: google-cloud-firestore google-cloud-functions