google-cloud-firestore - 云存储功能不是从应用程序(flutter)触发,而是在直接在firestore中进行更改时触发
问题描述
我有一个文档,其中有两个字段;
类别和持续时间(以微毫秒为单位)。类别可以有多个值,如类别 1、类别 2 等。
我想计算类别 == category1 的所有文档的持续时间总和。我对这里的代码做了一些更改,它现在可以工作了。但是我有一个奇怪的问题,当我通过应用程序界面进行更改时,更新没有被触发。应用程序可以正常创建。但是当我直接在firestore中进行更改时,更新工作正常。请帮忙。
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'
admin.initializeApp()
export const updateData =
functions.firestore.document('users/{UserId}/count/{uid}')
.onWrite(async(change, _) => await dataUpdates(change))
async function dataUpdates (change:
functions.Change<functions.firestore.DocumentSnapshot>){
const chartRating = change.after.ref.parent
let title = (await chartRating.where('Title', '==', 'Game').get()).size;
//duration
const restaurantRef = chartRating.parent!
console.log('{restaurantRef.path} now has ${Title}')
await restaurantRef.update({
Title: Title,
})
解决方案
推荐阅读
- kubernetes - 检查 Kubernetes 集群中的存储容量
- swift - 添加与 indexPath 一样多的数据 - Swift
- mysql - 从 IsoWeek 获取开始日期
- flutter - 带有 SnackBar 的底部 TextField
- javascript - 与 Internet Explorer 11 中 Google Chrome 的“添加源地图...”的功能等效
- linux - 有谁知道如何使用 CURL “伪造”下载?
- html - 如何在 CSS 中为标题创建响应式底部边框?
- sql-server - SQL Server 2005 从表 1 和表 2 中选择数据,但如果表 2 列 1 值为空 从表 3 中选择数据
- asp.net-core - Web App 的 Azure ADB2C 应用注册是否需要 App Key?
- java - 无法构造org.codehaus.jackson.map.type.SimpleType的实例,问题:抽象类型只能被实例化