packages/frm/src/builder.js
function activateField(model, fields) {
  let activeFields = [];
  if (fields === true) { // activate all
    return Object.keys(model.def.fields);
  } else if (Array.isArray(fields)) {
    activeFields = fields;
  } else if (typeof fields === 'string') {
    if (fields.indexOf('*') >= 0) { // activate all
      activeFields = Object.keys(model.def.fields);
    } else {
      activeFields = fields.trim().split(/\s*,\s*/);
    }
  }
  if (activeFields.length <= 0) throw new QueryError(model.name, 'fields required in find');

  // activate the related fields
  return Object.keys(activateRelatedFields(model, activeFields));
}
function activateField(model, fields) {
  let activeFields = [];
  if (fields === true) { // activate all
    return Object.keys(model.def.fields);
  } else if (Array.isArray(fields)) {
    activeFields = fields;
  } else if (typeof fields === 'string') {
    if (fields.indexOf('*') >= 0) { // activate all
      activeFields = Object.keys(model.def.fields);
    } else {
      activeFields = fields.trim().split(/\s*,\s*/);
    }
  }
  if (activeFields.length <= 0) throw new QueryError(model.name, 'fields required in find');

  // activate the related fields
  return Object.keys(activateRelatedFields(model, activeFields));
}
function activateField ( model , fields ) { let activeFields = [ ] ; if ( fields === true ) { // activate all return Object . keys ( model . def . fields ) ; } else if ( Array . isArray ( fields ) ) { activeFields = fields ; } else if ( typeof fields === 'string' ) { if ( fields . indexOf ( '*' ) >= 0 ) { // activate all activeFields = Object . keys ( model . def . fields ) ; } else { activeFields = fields . trim ( ) . split ( / \s*,\s* / ) ; } } if ( activeFields . length <= 0 ) throw new QueryError ( model . name , 'fields required in find' ) ; // activate the related fields return Object . keys ( activateRelatedFields ( model , activeFields ) ) ; }
parse the active fields, which will be used as select field list in sql statement
parse the active fields which will be used as select field list in sql statement