gpt4 book ai didi

firebase - 在同一时间更新不同路径的2个字段是否算作Cloud Firestore中的2个写入?

转载 作者:行者123 更新时间:2023-12-03 04:23:41 25 4
gpt4 key购买 nike

截屏1:

enter image description here

student > 100 > name,我想将'name'更新为'Bar'

屏幕截图2:

enter image description here

student > 100 > exam > english > marks,我想将'marks'更新为50

现在,我可以使用

var firestore = Firestore.instance;
firestore.document('student/100').updateData({'name': 'Bar'});
firestore.document('student/100/exams/english').updateData({'marks': 50});

问题:

此代码被调用两次:
var ref = firestore.document('student/100');
ref.snapshots().listen((event) {
print('server updated'); // called 2 times
});

这算作两次写吗?如果是,我如何将其更改为一次写入,因为两个字段都属于同一路径 'student/100'

最佳答案

Will this be counted as two write?



是的,它将被视为两次写入。

When you use Cloud Firestore, you are charged for the following:


  • 您执行的读取,写入和删除的次数。
  • 数据库使用的存储量,包括元数据和索引的开销。
  • 您使用的网络带宽量。

  • If yes, how can I change it to one write because both the fields belong to same path 'student/100'?



    在Firestore中,查询很浅,这意味着当您在顶层集合下写入文档时,除非您指定指向该文档的路径,否则无法访问子集合内的文档。因此,不可能同时对顶级文档和子集合内的文档执行一次写操作。

    关于firebase - 在同一时间更新不同路径的2个字段是否算作Cloud Firestore中的2个写入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61097146/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com