lib/class/Field.js
function _updateTHIS (model, obj) {
  const RESULT = {}
  if (Array.isArray(obj)) {
    return [_updateTHIS(model, obj[0])]
  }
  Object.keys(obj).forEach(prop => {
    const OBJ = obj[prop]
    if (_isTHIS(OBJ)) {
      delete OBJ._this
      RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
      return
    }
    if (_isField(OBJ)) {
      OBJ.fieldName = OBJ.fieldName || prop
      OBJ.field     = OBJ.field     || prop
      RESULT[prop] = OBJ
      return
    }
    if (typeof OBJ === 'object') {
      const SUB_MODEL = (model && model.associations[prop]) ? model.associations[prop].target : undefined
      RESULT[prop] = _updateTHIS(SUB_MODEL, OBJ)
    }
  })
  return RESULT
}
function _updateTHIS (model, obj) {
  const RESULT = {}
  if (Array.isArray(obj)) {
    return [_updateTHIS(model, obj[0])]
  }
  Object.keys(obj).forEach(prop => {
    const OBJ = obj[prop]
    if (_isTHIS(OBJ)) {
      delete OBJ._this
      RESULT[prop] = Object.assign(_.cloneDeep(model.attributes[prop]), OBJ)
      return
    }
    if (_isField(OBJ)) {
      OBJ.fieldName = OBJ.fieldName || prop
      OBJ.field     = OBJ.field     || prop
      RESULT[prop] = OBJ
      return
    }
    if (typeof OBJ === 'object') {
      const SUB_MODEL = (model && model.associations[prop]) ? model.associations[prop].target : undefined
      RESULT[prop] = _updateTHIS(SUB_MODEL, OBJ)
    }
  })
  return RESULT
}
function _updateTHIS ( model , obj ) { const RESULT = { } if ( Array . isArray ( obj ) ) { return [ _updateTHIS ( model , obj [ 0 ] ) ] } Object . keys ( obj ) . forEach ( prop => { const OBJ = obj [ prop ] if ( _isTHIS ( OBJ ) ) { delete OBJ . _this RESULT [ prop ] = Object . assign ( _ . cloneDeep ( model . attributes [ prop ] ) , OBJ ) return } if ( _isField ( OBJ ) ) { OBJ . fieldName = OBJ . fieldName || prop OBJ . field = OBJ . field || prop RESULT [ prop ] = OBJ return } if ( typeof OBJ === 'object' ) { const SUB_MODEL = ( model && model . associations [ prop ] ) ? model . associations [ prop ] . target : undefined RESULT [ prop ] = _updateTHIS ( SUB_MODEL , OBJ ) } } ) return RESULT }
Devuelve un objeto cuyos campos han sido definidos como THIS, con el valor que le corresponde.
Si el atributo no tiene un fieldName, se le asigna uno.
@param {SequelizeModel} model - Modelo Sequelize
@param {Object}         obj   - Objeto (grupo de fields).
@return {Object}
Devuelve un objeto cuyos campos han sido definidos como THIS con el valor que le corresponde . Si el atributo no tiene un fieldName se le asigna uno .