node_modules/@google-cloud/firestore/build/src/index.js
/**
     * Executes the given updateFunction and commits the changes applied within
     * the transaction.
     *
     * You can use the transaction object passed to 'updateFunction' to read and
     * modify Firestore documents under lock. Transactions are committed once
     * 'updateFunction' resolves and attempted up to five times on failure.
     *
     * @param {function(Transaction)} updateFunction The function to execute
     * within the transaction context.
     * @param {object=} transactionOptions Transaction options.
     * @param {number=} transactionOptions.maxAttempts - The maximum number of
     * attempts for this transaction.
     * @returns {Promise} If the transaction completed successfully or was
     * explicitly aborted (by the updateFunction returning a failed Promise), the
     * Promise returned by the updateFunction will be returned here. Else if the
     * transaction failed, a rejected Promise with the corresponding failure
     * error will be returned.
     *
     * @example
     * let counterTransaction = firestore.runTransaction(transaction => {
     *   let documentRef = firestore.doc('col/doc');
     *   return transaction.get(documentRef).then(doc => {
     *     if (doc.exists) {
     *       let count =  doc.get('count') || 0;
     *       if (count > 10) {
     *         return Promise.reject('Reached maximum count');
     *       }
     *       transaction.update(documentRef, { count: ++count });
     *       return Promise.resolve(count);
     *     }
     *
     *     transaction.create(documentRef, { count: 1 });
     *     return Promise.resolve(1);
     *   });
     * });
     *
     * counterTransaction.then(res => {
     *   console.log(`Count updated to ${res}`);
     * });
     */
Executes the given updateFunction and commits the changes applied within
the transaction.

You can use the transaction object passed to 'updateFunction' to read and
modify Firestore documents under lock. Transactions are committed once
'updateFunction' resolves and attempted up to five times on failure.

@param {function(Transaction)} updateFunction The function to execute
within the transaction context.
@param {object=} transactionOptions Transaction options.
@param {number=} transactionOptions.maxAttempts - The maximum number of
attempts for this transaction.
@returns {Promise} If the transaction completed successfully or was
explicitly aborted (by the updateFunction returning a failed Promise), the
Promise returned by the updateFunction will be returned here. Else if the
transaction failed, a rejected Promise with the corresponding failure
error will be returned.






Executes the given updateFunction and commits the changes applied within the transaction . You can use the transaction object passed to ' updateFunction ' to read and modify Firestore documents under lock . Transactions are committed once ' updateFunction ' resolves and attempted up to five times on failure . @param { function ( Transaction ) } updateFunction The function to execute within the transaction context . @param { object = } transactionOptions Transaction options . @param { number = } transactionOptions . maxAttempts - The maximum number of attempts for this transaction . @returns { Promise } If the transaction completed successfully or was explicitly aborted ( by the updateFunction returning a failed Promise ) the Promise returned by the updateFunction will be returned here . Else if the transaction failed a rejected Promise with the corresponding failure error will be returned .
runTransaction(updateFunction, transactionOptions) {
        validate_1.validateFunction('updateFunction', updateFunction);
        const defaultAttempts = 5;
        const tag = util_1.requestTag();
        let maxAttempts;
        if (transactionOptions) {
            validate_1.validateObject('transactionOptions', transactionOptions);
            validate_1.validateInteger('transactionOptions.maxAttempts', transactionOptions.maxAttempts, { optional: true, minValue: 1 });
            maxAttempts = transactionOptions.maxAttempts || defaultAttempts;
        }
        else {
            maxAttempts = defaultAttempts;
        }
        const transaction = new transaction_1.Transaction(this, tag);
        return this.initializeIfNeeded(tag).then(() => transaction.runTransaction(updateFunction, maxAttempts));
    }
runTransaction ( updateFunction , transactionOptions ) { validate_1 . validateFunction ( 'updateFunction' , updateFunction ) ; const defaultAttempts = 5 ; const tag = util_1 . requestTag ( ) ; let maxAttempts ; if ( transactionOptions ) { validate_1 . validateObject ( 'transactionOptions' , transactionOptions ) ; validate_1 . validateInteger ( 'transactionOptions.maxAttempts' , transactionOptions . maxAttempts , { optional : true , minValue : 1 } ) ; maxAttempts = transactionOptions . maxAttempts || defaultAttempts ; } else { maxAttempts = defaultAttempts ; } const transaction = new transaction_1 . Transaction ( this , tag ) ; return this . initializeIfNeeded ( tag ) . then ( ( ) => transaction . runTransaction ( updateFunction , maxAttempts ) ) ; }
Executes the given updateFunction and commits the changes applied within
 the transaction.
Executes the given updateFunction and commits the changes applied within the transaction .