function doRemoveDatasetClients(datasetClientsToRemove, cb) {
  var removeIds = _.pluck(datasetClientsToRemove, 'id');
  var datasetIds = _.uniq(_.pluck(datasetClientsToRemove, 'datasetId'));
  debug('doRemoveDatasetClients: removed datasetClients = %d, datasets = %d', removeIds.length, datasetIds.length);
  async.series([
    function deleteDatasetClientAndRefs(callback) {
      async.map(removeIds, doRemoveDatasetClientWithRecords, function(err, deleteResult) {
        if (err) {
          debug('Failed to delete datasetClients due to error %s', err);
        }
        return callback(err, deleteResult);
      });
    },
    function removeUnusedRecords(callback) {
      async.map(datasetIds, removeRecordsForDataset, function(err, deletedCount) {
        if (err) {
          debug('Error occured when delete records for dataset due to error %s', err);
        }
        return callback(err, deletedCount);
      });
    }
  ], function(err, results){
    if (err) {
      return cb(err);
    } else {
      return cb(null, results[0]);
    }
  });
}
function doRemoveDatasetClients(datasetClientsToRemove, cb) {
  var removeIds = _.pluck(datasetClientsToRemove, 'id');
  var datasetIds = _.uniq(_.pluck(datasetClientsToRemove, 'datasetId'));
  debug('doRemoveDatasetClients: removed datasetClients = %d, datasets = %d', removeIds.length, datasetIds.length);
  async.series([
    function deleteDatasetClientAndRefs(callback) {
      async.map(removeIds, doRemoveDatasetClientWithRecords, function(err, deleteResult) {
        if (err) {
          debug('Failed to delete datasetClients due to error %s', err);
        }
        return callback(err, deleteResult);
      });
    },
    function removeUnusedRecords(callback) {
      async.map(datasetIds, removeRecordsForDataset, function(err, deletedCount) {
        if (err) {
          debug('Error occured when delete records for dataset due to error %s', err);
        }
        return callback(err, deletedCount);
      });
    }
  ], function(err, results){
    if (err) {
      return cb(err);
    } else {
      return cb(null, results[0]);
    }
  });
}
function doRemoveDatasetClients ( datasetClientsToRemove , cb ) { var removeIds = _ . pluck ( datasetClientsToRemove , 'id' ) ; var datasetIds = _ . uniq ( _ . pluck ( datasetClientsToRemove , 'datasetId' ) ) ; debug ( 'doRemoveDatasetClients: removed datasetClients = %d, datasets = %d' , removeIds . length , datasetIds . length ) ; async . series ( [ function deleteDatasetClientAndRefs ( callback ) { async . map ( removeIds , doRemoveDatasetClientWithRecords , function ( err , deleteResult ) { if ( err ) { debug ( 'Failed to delete datasetClients due to error %s' , err ) ; } return callback ( err , deleteResult ) ; } ) ; } , function removeUnusedRecords ( callback ) { async . map ( datasetIds , removeRecordsForDataset , function ( err , deletedCount ) { if ( err ) { debug ( 'Error occured when delete records for dataset due to error %s' , err ) ; } return callback ( err , deletedCount ) ; } ) ; } ] , function ( err , results ) { if ( err ) { return cb ( err ) ; } else { return cb ( null , results [ 0 ] ) ; } } ) ; }
Remove the given datasetClients
@param {storage~DatasetClient[]} datasetClientsToRemove an array of datasetClients to remove. Each of them should have an `id` field
@param {Function} cb
Remove the given datasetClients