Firebase firestore:云功能未正确部署

时间:2018-03-01 10:56:07

标签: javascript firebase google-cloud-functions google-cloud-firestore

我正在尝试使用云功能从云端防火墙获取文档数据。但我收到错误Failed to configure trigger providers/cloud.firestore/eventTypes/document.write@firestore.googleapis.com (Split)

Error: Functions did not deploy properly.

我尝试了很多选项,例如更新我的firebase工具,更改功能名称和已部署但仍然遇到相同的错误。  这是代码

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);
        const db = admin.firestore();
        exports.splitting = functions.firestore
            .document('deyaPayUsers/{authid}/Split/{authid}/SentInvitations/{autoid}')
            .onWrite(event =>{
            const ID = event.params.authid;
            const splitid = event.params.autoid;
            var document = event.data.data();
            //retrieve the data from the database and stored into document
            var ph1 = document.Invite1.PhoneNumber;
            console.log(document);
            console.log(ph1);
           });

我的数据库路径

/deyaPayUsers //collections
{authid}    //Document
/Split      //Collection
{authid}    //Document
/SentInvitations //Collection
{autoid}         //document
   Invite1     //object
     PhoneNumber: 987654321, //number
     Amount:21               //number

1 个答案:

答案 0 :(得分:5)

authid通配符使用两次:

.document('deyaPayUsers/{authid}/Split/{authid}/SentInvitations/{autoid}')

为每个通配符使用唯一名称:

.document('deyaPayUsers/{authid}/Split/{authid2}/SentInvitations/{autoid}')