lib/mongodb/mongodb/lib/bulk/unordered.js
function executeBatches(bulkOperation, options, callback) {
  let numberOfCommandsToExecute = bulkOperation.s.batches.length;
  // Execute over all the batches
  for (let i = 0; i < bulkOperation.s.batches.length; i++) {
    executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
      // Count down the number of commands left to execute
      numberOfCommandsToExecute = numberOfCommandsToExecute - 1;

      // Execute
      if (numberOfCommandsToExecute === 0) {
        // Driver level error
        if (err) return handleCallback(callback, err);

        const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
        if (bulkOperation.handleWriteError(callback, writeResult)) return;

        return handleCallback(callback, null, writeResult);
      }
    });
  }
}
function executeBatches(bulkOperation, options, callback) {
  let numberOfCommandsToExecute = bulkOperation.s.batches.length;
  // Execute over all the batches
  for (let i = 0; i < bulkOperation.s.batches.length; i++) {
    executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
      // Count down the number of commands left to execute
      numberOfCommandsToExecute = numberOfCommandsToExecute - 1;

      // Execute
      if (numberOfCommandsToExecute === 0) {
        // Driver level error
        if (err) return handleCallback(callback, err);

        const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
        if (bulkOperation.handleWriteError(callback, writeResult)) return;

        return handleCallback(callback, null, writeResult);
      }
    });
  }
}
function executeBatches ( bulkOperation , options , callback ) { let numberOfCommandsToExecute = bulkOperation . s . batches . length ; // Execute over all the batches for ( let i = 0 ; i < bulkOperation . s . batches . length ; i ++ ) { executeBatch ( bulkOperation , bulkOperation . s . batches [ i ] , options , function ( err ) { // Count down the number of commands left to execute numberOfCommandsToExecute = numberOfCommandsToExecute - 1 ; // Execute if ( numberOfCommandsToExecute === 0 ) { // Driver level error if ( err ) return handleCallback ( callback , err ) ; const writeResult = new BulkWriteResult ( bulkOperation . s . bulkResult ) ; if ( bulkOperation . handleWriteError ( callback , writeResult ) ) return ; return handleCallback ( callback , null , writeResult ) ; } } ) ; } }
Execute all the commands

@param {UnorderedBulkOperation} bulkOperation
@param {object} options
@param {function} callback
Execute all the commands