app/services/date-type.service.js
// Recursively loop through the all nested properties of the object
Recursively loop through the all nested properties of the object
Recursively loop through the all nested properties of the object
function traverseLevel(objP, objN) {
    _.forEach(objP, (field, key) => {
      if (typeof field === 'object') {
        if (field instanceof Date) {
          if (objN[key]) {
            objN[key] = new Date(objN[key]);
          }
        } else if (!_.isEmpty(field) && !_.isEmpty(objN[key])) {
          traverseLevel(field, objN[key]);
        }
      }
    });
  }
function traverseLevel ( objP , objN ) { _ . forEach ( objP , ( field , key ) => { if ( typeof field === 'object' ) { if ( field instanceof Date ) { if ( objN [ key ] ) { objN [ key ] = new Date ( objN [ key ] ) ; } } else if ( ! _ . isEmpty ( field ) && ! _ . isEmpty ( objN [ key ] ) ) { traverseLevel ( field , objN [ key ] ) ; } } } ) ; }
Recursively loop through the all nested properties of the object
Recursively loop through the all nested properties of the object
// We only care about Object types (the javascript class Date is an object type) // If this field on the record was a Date type, convert the string that field to a Date object // Traverse further if this is a nested object