code: function buildCompositeForm(formSubmissionModel, formId, singleFormQuery, statusUpdaterFunction, cb) {
    var mergedFields = {};
    mergedFields[formId] = {};
  
    logger.debug("buildCompositeForm start");
  
    statusUpdaterFunction({
      message: "Creating form metadata for submissions with form ID: " + formId
    });
  
    var mapReduceOptions = {
      map: function() {
        //The only difference will be the "lastUpdated" timestamp.
        emit(this.formSubmittedAgainst.lastUpdated, this.formSubmittedAgainst); // eslint-disable-line no-undef
      },
      reduce: function(lastUpdatedTimestamp, formEntries) {
        //Only want one of each form definition for each different timestamp
        var formEntry = formEntries[0];
  
        //Only need the pages, _id and name
        if (formEntry && formEntry.pages) {
          return {
            _id: formEntry._id,
            name: formEntry.name,
            pages: formEntry.pages
          };
        } else {
          return null;
        }
      },
      query: singleFormQuery
    };
  
    formSubmissionModel.mapReduce(mapReduceOptions, function(err, subFormsSubmittedAgainst) {
      if (err) {
        logger.error("Error Using mapReduce ", err);
        return cb(err);
      }
  
      statusUpdaterFunction({
        message: "Finished Creating form metadata for submissions with form ID: " + formId
      });
  
      logger.debug("buildCompositeForm finish");
  
      var formName = "";
  
      _.each(subFormsSubmittedAgainst, function(subFormSubmittedAgainst) {
        formName = formName || subFormSubmittedAgainst.value.name;
        mergedFields[formId] = mergeFormFields(mergedFields[formId] || {}, subFormSubmittedAgainst.value);
      });
  
      return cb(null, mergedFields, formName);
    });
  }
docs: buildCompositeForm - Building a merged list of fields based on the
  
  @param  {Model}  formSubmissionModel The Submission mongoose Model
  @param  {string} formId              The ID of the form to search for
  @param  {object} singleFormQuery     A mongo query to find all of the submissions to search for
  @param  {function} statusUpdaterFunction  A function to update the status of an async submission export
  @param  {function} cb