如何将每次将新文档从Android添加到防火墙时生成的DocumentReference.getId()发送到云函数,以便在Firestore上执行写/创建操作时触发该函数。我试着跟着
'use strict';
const https = require( 'firebase-functions');
const functions = require('firebase-functions');
const Firestore = require('@google-cloud/firestore');
const firestore = new Firestore();
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.helloUser = functions.firestore
.document('BankInform/Moj2HBrxepX5R7FonvrO')
.onUpdate(event =>{
var newValue = event.data.data();
return event.data.ref.update({
"status": "Success"
});
});但是我必须给出document.How的自动id,以便将文档id从android传递给云功能。
发布于 2017-10-16 16:39:23
您希望在函数中使用通配符:
exports.helloUser = functions.firestore
.document('BankInform/{transactionId}')
.onUpdate(event =>{
var transactionId = event.params.transactionId
console.log(transactionId); // Moj2HBrxepX5R7FonvrO
});如您所见,您应该能够使用event.params从函数中获取适当的文档名称。
https://stackoverflow.com/questions/46766157
复制相似问题