每当要将新集合添加到云防火墙时,都必须发生云防火墙触发器。云功能已成功执行,但是当新文档添加到firestore时它们不会触发,这意味着日志为空,执行次数为0.以下是云功能代码。
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.wallet=functions.firestore
.document('Samyata/{authid}')
.onCreate(event => {
const db = admin.firestore();
const ID = event.params.authId
var pymntDetails = db.collection('Samyata').doc(ID).collection('Accounts').doc(ID);
var details = pymntDetails.set({
'stripecustomerId':'0',
//var bankAccount = db.collection('Samyata').doc(ID).collection('Accounts').doc(ID).doc('BankDetails');
//var bnkdetails = bankAccount.set({
//'AccountNumber':'',
//'RoutingNumber':''
//});//SET CLOSE for bank details
'deyaCoins':'0',
'BitCoins':'0',
'Ether':'0'
});//matched set paranthesis
return event.data.ref.update({
ID
});
});//end of onCreate event
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });