在 Firestore 事务中更新同一文档的多个字段时的定价

Pricing when updating more than one field of the same document within a Firestore transaction

我使用 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);
    }
});

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

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?

无论您在一次操作中更改了文档中的多少个字段,您始终需要支付一次写入操作的费用。如果您一个接一个地进行写入,您将被收取两次写入操作的费用。