javascript - 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. 上传代码时,它说它希望在这里捕获或返回。
解决方案
推荐阅读
- javascript - Javascript:具有相同值的对象数组的每个元素
- python - 加载的 LGBM 模型如何在不同的机器上产生不同的预测?
- javascript - 在where子句中对连接进行sequalize join以关联两个表
- android - 即使在 Android 应用程序关闭时也持续进行 API 调用 - RxJava
- php - 在 Mediawiki 的 php 框架中创建 SQL 连接
- python - 为什么在类中调用另一个函数时会收到“名称未定义”错误消息?
- c++ - 结构的 std::vector:调整矢量大小后结构成员的初始值是多少?
- formatting - man – 我怎样才能使单词斜体的一部分?
- java - 3的中位数比java中通常的快速排序花费更多时间
- java - 如何在 JAX-RS 中使数据字段成为可选(非必需)?