首页 > 解决方案 > Firebase 云函数嵌套然后写入

问题描述

我正在编写一个需要我验证交易并记录它们的应用程序。我的函数中的一些代码如下所示:

snapshot.after.ref.parent.parent.child('liquidAssets').set(newLiquidAssets).then( function(){
                snapshot.after.ref.parent.parent.child('transactions').push({
                timestamp: tinestampOfTransaction,
                transaction: transaction,
                stock: tickerSymbol,
                volume: sharesToBuy,
                price: currPrice
              }).then( function(){
                return 1;
              });
            });

我只想在设置完成后添加事务日志。推送后我想返回 1. 上传代码时,它说它希望在这里捕获或返回。

标签: javascriptfirebasefirebase-realtime-databasepromisegoogle-cloud-functions

解决方案


推荐阅读