Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在Firestore事务中更新同一文档的多个字段时的定价_Android_Transactions_Google Cloud Firestore_Billing_Acid - Fatal编程技术网

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

Android 在Firestore事务中更新同一文档的多个字段时的定价,android,transactions,google-cloud-firestore,billing,acid,Android,Transactions,Google Cloud Firestore,Billing,Acid,我使用Firestore进行了以下交易: mDb.runTransaction(new Transaction.Function<Void>() { @Override public Void apply(final Transaction transaction) throws FirebaseFirestoreException { DocumentReference documentReference = mDb.collection("coll

我使用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);
    }
});
mDb.runTransaction(new Transaction.Function(){
@凌驾
public Void apply(最终事务)引发FirebaseFirestoreException{
DocumentReference DocumentReference=mDb.collection(“collectionOne”).document(“documentOne”);
/*
一些代码
*/
transaction.update(documentReference,App.getresources().getString(R.string.field_one),FieldValue.increment(1));
transaction.update(documentReference,App.getresources().getString(R.string.field_two),FieldValue.increment(1));
返回null;
}
}).addOnSuccessListener(新的OnSuccessListener(){
@凌驾
成功时公开作废(作废避免){
Log.d(“调试”,“事务正确执行”);
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
Log.w(“调试”,“事务失败”,e);
}
});
我的问题是:例如,当更新同一事务中同一文档的两个字段时,这样的事务会产生一个或两个文档读取吗

例如,当更新同一事务中同一文档的两个字段时,这样的事务会产生一个或两个文档读取吗


无论您在一次操作中更改文档中的多少字段,您总是要承担一次写入操作的费用。如果您一个接一个地进行写入,您将被收取两次写入操作的费用。

一个事务被视为一次操作,还是其正文中的更新/设置/删除的总数?换言之,在初始问题的代码中,一次或两次读取将收取交易费用?只要您修改同一文档中的字段,一次交易将被视为一次操作。在您的情况下,事务将只花费您一次读取操作。