lib/impl/getSubmissions/buildQuery.js
function buildSingleFilterQueryObject(paginationFilter) {
  return function(submissionQueryField) {
    var fieldQuery = {
    };

    //formId and _id fields are ObjectIds. They must be valid in order to search for them.
    if (submissionQueryField === 'formId' || submissionQueryField === '_id') {
      if (mongoose.Types.ObjectId.isValid(paginationFilter)) {
        //Cannot use $regex when searching for ObjectIDs
        fieldQuery[submissionQueryField] = new mongoose.Types.ObjectId(paginationFilter);
      } else {
        //not a valid objectId, don't want to search for it.
        return null;
      }
    } else {
      fieldQuery[submissionQueryField] = {$regex: paginationFilter, $options: 'i'};
    }

    return fieldQuery;
  };
}
function buildSingleFilterQueryObject(paginationFilter) {
  return function(submissionQueryField) {
    var fieldQuery = {
    };

    //formId and _id fields are ObjectIds. They must be valid in order to search for them.
    if (submissionQueryField === 'formId' || submissionQueryField === '_id') {
      if (mongoose.Types.ObjectId.isValid(paginationFilter)) {
        //Cannot use $regex when searching for ObjectIDs
        fieldQuery[submissionQueryField] = new mongoose.Types.ObjectId(paginationFilter);
      } else {
        //not a valid objectId, don't want to search for it.
        return null;
      }
    } else {
      fieldQuery[submissionQueryField] = {$regex: paginationFilter, $options: 'i'};
    }

    return fieldQuery;
  };
}
function buildSingleFilterQueryObject ( paginationFilter ) { return function ( submissionQueryField ) { var fieldQuery = { } ; //formId and _id fields are ObjectIds. They must be valid in order to search for them. if ( submissionQueryField === 'formId' || submissionQueryField === '_id' ) { if ( mongoose . Types . ObjectId . isValid ( paginationFilter ) ) { //Cannot use $regex when searching for ObjectIDs fieldQuery [ submissionQueryField ] = new mongoose . Types . ObjectId ( paginationFilter ) ; } else { //not a valid objectId, don't want to search for it. return null ; } } else { fieldQuery [ submissionQueryField ] = { $regex : paginationFilter , $options : 'i' } ; } return fieldQuery ; } ; }
buildSingleFilterQueryObject - Building a query object based on the field to be queried

@param  {string} paginationFilter     Filter value
@return {object}                      Generated Query for the field
buildSingleFilterQueryObject - Building a query object based on the field to be queried