lib/storage/dataset-clients.js
function doReadDatasetClientWithRecords(datasetClientId, callback) {
  debug('doReadDatasetClientWithRecords datasetClientId = ', datasetClientId);
  async.waterfall([
    async.apply(doReadDatasetClient, datasetClientId),
    function listRecords(datasetClientJson, next) {
      if (datasetClientJson) {
        listDatasetClientRecords(datasetClientJson, null, function(err, localRecords) {
          return next(err, datasetClientJson, localRecords);
        });
      } else {
        return next();
      }
    }
  ], function(err, datasetClientJson, localRecords) {
    if (err) {
      debugError('Failed to doReadDatasetClientWithRecords due to error %s :: datasetClientId = %s', err, datasetClientId);
      return callback(err);
    }
    if (datasetClientJson) {
      datasetClientJson.records = localRecords;
    }
    return callback(null, datasetClientJson);
  });
}
function doReadDatasetClientWithRecords(datasetClientId, callback) {
  debug('doReadDatasetClientWithRecords datasetClientId = ', datasetClientId);
  async.waterfall([
    async.apply(doReadDatasetClient, datasetClientId),
    function listRecords(datasetClientJson, next) {
      if (datasetClientJson) {
        listDatasetClientRecords(datasetClientJson, null, function(err, localRecords) {
          return next(err, datasetClientJson, localRecords);
        });
      } else {
        return next();
      }
    }
  ], function(err, datasetClientJson, localRecords) {
    if (err) {
      debugError('Failed to doReadDatasetClientWithRecords due to error %s :: datasetClientId = %s', err, datasetClientId);
      return callback(err);
    }
    if (datasetClientJson) {
      datasetClientJson.records = localRecords;
    }
    return callback(null, datasetClientJson);
  });
}
function doReadDatasetClientWithRecords ( datasetClientId , callback ) { debug ( 'doReadDatasetClientWithRecords datasetClientId = ' , datasetClientId ) ; async . waterfall ( [ async . apply ( doReadDatasetClient , datasetClientId ) , function listRecords ( datasetClientJson , next ) { if ( datasetClientJson ) { listDatasetClientRecords ( datasetClientJson , null , function ( err , localRecords ) { return next ( err , datasetClientJson , localRecords ) ; } ) ; } else { return next ( ) ; } } ] , function ( err , datasetClientJson , localRecords ) { if ( err ) { debugError ( 'Failed to doReadDatasetClientWithRecords due to error %s :: datasetClientId = %s' , err , datasetClientId ) ; return callback ( err ) ; } if ( datasetClientJson ) { datasetClientJson . records = localRecords ; } return callback ( null , datasetClientJson ) ; } ) ; }
Read the dataset client object from the `fhsync-datasetClients` collection, as well as the associated records for the datasetClient from the `fhsync-<datasetId>-records` collection.
The records will be added to the datasetClient json object with the key `records`
@param {String} datasetClientId
@param {Function} callback
Read the dataset client object from the fhsync - datasetClients collection as well as the associated records for the datasetClient from the fhsync - <datasetId > - records collection . The records will be added to the datasetClient json object with the key records