Cloud Functions not Working

Viewed 1174

A cloud firestore trigger has to happen whenever a new collection is to added to the cloud firestore. The cloud functions are successfully executed, but they are not triggering when a new doc was added to the firestore it means the logs are empty and no.of execute times is 0.The following the cloud function code.

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!");
// });
0 Answers
Related