lib/loader.js
function ToJSON(jsonName) {
        if (jsonName === 'result') jsonName = 'default';
        let args = Array.prototype.slice.call(arguments);
        if (typeof jsonName === 'undefined') {
          jsonName = 'default';
        } else if (typeof jsonName === 'string') {
          args.splice(0, 1);  //remove the name.
        }
        let jsonFn = modelObj.jsons[jsonName],
          result = this.dataValues;
        if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
          if (typeof modelObj.jsons['default'] === 'function') {
            result = modelObj.jsons['default'].apply(this, args);
          }
        } else {
          if (typeof modelObj.jsons[jsonName] === 'function') {
            result = modelObj.jsons[jsonName].apply(this, args);
          } else {
            result = this.dataValues;
          }
        }
        if (result === this) {
          result = this.dataValues;
        }
        if (typeof result === 'object' && result != null) {
          for (let i = 0; i < modelObj.privateAttributes.length; i++) {
            if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
              delete result[modelObj.privateAttributes[i]];
            }
          }
        }
        return result;
      }
function ToJSON(jsonName) {
        if (jsonName === 'result') jsonName = 'default';
        let args = Array.prototype.slice.call(arguments);
        if (typeof jsonName === 'undefined') {
          jsonName = 'default';
        } else if (typeof jsonName === 'string') {
          args.splice(0, 1);  //remove the name.
        }
        let jsonFn = modelObj.jsons[jsonName],
          result = this.dataValues;
        if (typeof jsonFn === 'undefined' && jsonName !== 'default') { // silent fallback
          if (typeof modelObj.jsons['default'] === 'function') {
            result = modelObj.jsons['default'].apply(this, args);
          }
        } else {
          if (typeof modelObj.jsons[jsonName] === 'function') {
            result = modelObj.jsons[jsonName].apply(this, args);
          } else {
            result = this.dataValues;
          }
        }
        if (result === this) {
          result = this.dataValues;
        }
        if (typeof result === 'object' && result != null) {
          for (let i = 0; i < modelObj.privateAttributes.length; i++) {
            if (typeof result[modelObj.privateAttributes[i]] !== 'undefined') {
              delete result[modelObj.privateAttributes[i]];
            }
          }
        }
        return result;
      }
function ToJSON ( jsonName ) { if ( jsonName === 'result' ) jsonName = 'default' ; let args = Array . prototype . slice . call ( arguments ) ; if ( typeof jsonName === 'undefined' ) { jsonName = 'default' ; } else if ( typeof jsonName === 'string' ) { args . splice ( 0 , 1 ) ; //remove the name. } let jsonFn = modelObj . jsons [ jsonName ] , result = this . dataValues ; if ( typeof jsonFn === 'undefined' && jsonName !== 'default' ) { // silent fallback if ( typeof modelObj . jsons [ 'default' ] === 'function' ) { result = modelObj . jsons [ 'default' ] . apply ( this , args ) ; } } else { if ( typeof modelObj . jsons [ jsonName ] === 'function' ) { result = modelObj . jsons [ jsonName ] . apply ( this , args ) ; } else { result = this . dataValues ; } } if ( result === this ) { result = this . dataValues ; } if ( typeof result === 'object' && result != null ) { for ( let i = 0 ; i < modelObj . privateAttributes . length ; i ++ ) { if ( typeof result [ modelObj . privateAttributes [ i ] ] !== 'undefined' ) { delete result [ modelObj . privateAttributes [ i ] ] ; } } } return result ; }
wrap the toJSON function to exclude private fields.
wrap the toJSON function to exclude private fields .