在Firestore交易中更新同一文档的多个字段时的定价 [英] Pricing when updating more than one field of the same document within a Firestore transaction

查看:80
本文介绍了在Firestore交易中更新同一文档的多个字段时的定价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Firestore进行以下交易:

I have the following transaction using Firestore:

mDb.runTransaction(new Transaction.Function<Void>() {
    @Override
    public Void apply(final Transaction transaction) throws FirebaseFirestoreException {
        DocumentReference documentReference = mDb.collection("collectionOne").document("documentOne");
        /*
            some code
        */
        transaction.update(documentReference, App.getResourses().getString(R.string.field_one), FieldValue.increment(1));
        transaction.update(documentReference, App.getResourses().getString(R.string.field_two), FieldValue.increment(1));
        return null;
    }
}).addOnSuccessListener(new OnSuccessListener<Void>() {
    @Override
    public void onSuccess(Void aVoid) {
        Log.d("Debugging", "Transaction correctly executed.");
    }
}).addOnFailureListener(new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
        Log.w("Debugging", "Transaction failure.", e);
    }
});

我的问题是:例如,在同一笔交易中更新同一文档的两个字段时,这样的交易会产生一个或两个文档吗?

My question is: when updating, for example, two fields of the same document within the same transaction, will such a transaction yield to one or two documents reads?

推荐答案

例如,在同一笔交易中更新同一文档的两个字段时,这样的交易会产生一个或两个文档读取吗?

when updating, for example, two fields of the same document within the same transaction, will such a transaction yield to one or two documents reads?

在一个操作中更改一个文档中的多少字段都无关紧要,您始终要承担一个写入操作的费用.如果您一次又一次地进行写操作,则将承担两次写操作的费用.

Doesn't matter how many fields you change in a document in one operation, you'll always be charged with one write operation. If you make the writes, one after the other, you'll be charged with two write operations.

这篇关于在Firestore交易中更新同一文档的多个字段时的定价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆