lib/impl/dataSources/update.js
function findDataSource(connections, dataSource, cb) {
  var query = {

  };

  //Searching By ID.
  query[CONSTANTS.DATA_SOURCE_ID] = dataSource[CONSTANTS.DATA_SOURCE_ID];

  //Looking up a full data source document as we are updating
  lookUpDataSources(connections, {
    query: query,
    lean: false
  }, function(err, dataSources) {
    if (err) {
      return cb(buildErrorResponse({
        error: err,
        userDetail: "Unexpected Error When Searching For A Data Source",
        code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
      }));
    }

    //Should only be one data source
    if (dataSources.length !== 1) {
      return cb(buildErrorResponse({
        error: new Error("Data Source Not Found"),
        systemDetail: "Requested ID: "  + dataSource[CONSTANTS.DATA_SOURCE_ID],
        code: ERROR_CODES.FH_FORMS_NOT_FOUND
      }));
    }

    return cb(undefined, dataSource, dataSources[0]);
  });
}
function findDataSource(connections, dataSource, cb) {
  var query = {

  };

  //Searching By ID.
  query[CONSTANTS.DATA_SOURCE_ID] = dataSource[CONSTANTS.DATA_SOURCE_ID];

  //Looking up a full data source document as we are updating
  lookUpDataSources(connections, {
    query: query,
    lean: false
  }, function(err, dataSources) {
    if (err) {
      return cb(buildErrorResponse({
        error: err,
        userDetail: "Unexpected Error When Searching For A Data Source",
        code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
      }));
    }

    //Should only be one data source
    if (dataSources.length !== 1) {
      return cb(buildErrorResponse({
        error: new Error("Data Source Not Found"),
        systemDetail: "Requested ID: "  + dataSource[CONSTANTS.DATA_SOURCE_ID],
        code: ERROR_CODES.FH_FORMS_NOT_FOUND
      }));
    }

    return cb(undefined, dataSource, dataSources[0]);
  });
}
function findDataSource ( connections , dataSource , cb ) { var query = { } ; //Searching By ID. query [ CONSTANTS . DATA_SOURCE_ID ] = dataSource [ CONSTANTS . DATA_SOURCE_ID ] ; //Looking up a full data source document as we are updating lookUpDataSources ( connections , { query : query , lean : false } , function ( err , dataSources ) { if ( err ) { return cb ( buildErrorResponse ( { error : err , userDetail : "Unexpected Error When Searching For A Data Source" , code : ERROR_CODES . FH_FORMS_UNEXPECTED_ERROR } ) ) ; } //Should only be one data source if ( dataSources . length !== 1 ) { return cb ( buildErrorResponse ( { error : new Error ( "Data Source Not Found" ) , systemDetail : "Requested ID: " + dataSource [ CONSTANTS . DATA_SOURCE_ID ] , code : ERROR_CODES . FH_FORMS_NOT_FOUND } ) ) ; } return cb ( undefined , dataSource , dataSources [ 0 ] ) ; } ) ; }
findDataSource - Finding A Data Source

@param  {object} connections Mongoose And Mongo Connections
@param  {object} dataSource  Data Source To Update
@param  {function} cb          Callback
@return {undefined}
findDataSource - Finding A Data Source