Get a list of fields that can be queried against.
@param model: A mongoose model object.
@param logger: A logging object.
@returns {Array}: A list of fields.
773383
function(model, logger) {
    // This line has to come first
    validationHelper.validateModel(model, logger)

    let queryableFields = []

    let fields = model.schema.paths
    let fieldNames = Object.keys(fields)

    let associations = model.routeOptions
      ? model.routeOptions.associations
      : null

    for (let i = 0; i < fieldNames.length; i++) {
      let fieldName = fieldNames[i]
      if (fields[fieldName] && fieldName !== '__v' && fieldName !== '__t') {
        let field = fields[fieldName].options
        let association = associations
          ? associations[fields[fieldName].path] || {}
          : {}

        // EXPL: by default we don't include MANY_MANY array references
        if (
          field.queryable !== false &&
          !field.exclude &&
          association.type !== 'MANY_MANY'
        ) {
          queryableFields.push(fieldName)
        }
      }
    }

    return queryableFields
  }
27965
def get_for_model(self, model):
        
        # Return empty queryset if the given object is not valid.
        if not issubclass(model, models.Model):
            return self.none()

        content_type = ContentType.objects.get_for_model(model)

        return self.filter(content_type=content_type)
558712
function(model, query, mongooseQuery, logger) {
    // This line has to come first
    validationHelper.validateModel(model, logger)
    const Log = logger.bind()
    // (email == 'test@user.com' && (firstName == 'test2@user.com' || firstName == 'test4@user.com')) && (age < 15 || age > 30)
    // LITERAL
    // {
    //  and: {
    //    email: {
    //      equal: 'test@user.com',
    //    },
    //    or: {
    //      firstName: {
    //        equal: ['test2@user.com', 'test4@user.com']
    //      }
    //    },
    //    age: {
    //      gt: '15',
    //      lt: '30'
    //    }
    //  }
    // {
    // and[email][equal]=test@user.com&and[or][firstName][equal]=test2@user.com&and[or][firstName][equal]=test4@user.com&and[age][gt]=15
    // ABBREVIATED
    // {
    //  email:'test@user.com',
    //  firstName: ['test2@user.com', 'test4@user.com'],
    //  age: {
    //    $or: {
    //      $gt: '15',
    //      $lt: '30'
    //    }
    //  }
    // }
    // [email]=test@user.com&[firstName]=test2@user.com&[firstName]=test4@user.com&[age][gt]=15&[age][lt]=30

    delete query[''] // EXPL: hack due to bug in hapi-swagger-docs

    delete query.$count

    mongooseQuery = this.setExclude(query, mongooseQuery, Log)

    let attributesFilter = this.createAttributesFilter(query, model, Log)
    if (attributesFilter === '') {
      attributesFilter = '_id'
    }

    let result = this.populateEmbeddedDocs(
      query,
      mongooseQuery,
      attributesFilter,
      model.routeOptions.associations,
      model,
      Log
    )
    mongooseQuery = result.mongooseQuery
    attributesFilter = result.attributesFilter

    mongooseQuery = this.setSort(query, mongooseQuery, Log)

    mongooseQuery.select(attributesFilter)

    if (typeof query.$where === 'string') {
      query.$where = JSON.parse(query.$where)
    }

    if (query.$where) {
      mongooseQuery.where(query.$where)
      delete query.$where
    }

    // EXPL: Support single (string) inputs or multiple "or'd" inputs (arrays) for field queries
    for (let fieldQueryKey in query) {
      let fieldQuery = query[fieldQueryKey]
      if (!Array.isArray(fieldQuery)) {
        fieldQuery = tryParseJSON(query[fieldQueryKey])
      }
      if (
        fieldQuery &&
        Array.isArray(fieldQuery) &&
        fieldQueryKey !== '$searchFields'
      ) {
        query[fieldQueryKey] = { $in: fieldQuery } // EXPL: "or" the inputs
      }
    }

    // EXPL: handle full text search
    if (query.$text) {
      query.$text = { $search: query.$text }
    }

    // EXPL: handle regex search
    this.setTermSearch(query, model, Log)

    let whereQuery = _.extend({}, query)

    // EXPL: delete pagination parameters
    delete whereQuery.$limit
    delete whereQuery.$skip
    delete whereQuery.$page

    mongooseQuery.where(whereQuery)
    return mongooseQuery
  }
864412
def get_field_list(fields, schema):
  
  # If the fields weren't supplied get them from the schema.
  if schema:
    all_fields = [f['name'] for f in schema._bq_schema if f['type'] != 'RECORD']

  if isinstance(fields, list):
    if schema:
      # validate fields exist
      for f in fields:
        if f not in all_fields:
          raise Exception('Cannot find field %s in given schema' % f)
    return fields
  if isinstance(fields, basestring) and fields != '*':
    if schema:
      # validate fields exist
      for f in fields.split(','):
        if f not in all_fields:
          raise Exception('Cannot find field %s in given schema' % f)
      return fields.split(',')
  if not schema:
    return []
  return all_fields
668668
def get_serializer_fields(self, path, method, view, version=None, method_func=None):
        
        if method in ('PUT', 'PATCH', 'POST'):
            location = 'form'
        else:
            location = 'query'

        serializer_class = self.get_serializer_class(view, method_func)
        if not serializer_class:
            return []

        serializer = serializer_class()
        if isinstance(serializer, serializers.ListSerializer):
            return [
                Field(
                    name='data',
                    location=location,
                    required=True,
                    schema=coreschema.Array()
                )
            ]

        if not isinstance(serializer, serializers.Serializer):
            return []

        fields = []
        for field in serializer.fields.values():
            if field.read_only or isinstance(field, serializers.HiddenField):
                continue

            required = field.required and method != 'PATCH'
            # if the attribute ('help_text') of this field is a lazy translation object, force it to generate a string
            description = str(field.help_text) if isinstance(field.help_text, Promise) else field.help_text
            fallback_schema = self.fallback_schema_from_field(field)
            field = Field(
                name=field.field_name,
                location=location,
                required=required,
                schema=fallback_schema if fallback_schema else field_to_schema(field),
                description=description,
            )
            fields.append(field)

        return fields
733797
def get_fields(self):
        
        ret = OrderedDict()

        # no rights to see anything
        if not self.user:
            return ret

        # all fields that can be accessed through serializer
        fields = super(ModelPermissionsSerializer, self).get_fields()

        # superuser can see all the fields
        if self.user.is_superuser:
            return fields

        # fields that can be accessed by auhtenticated user
        allowed_fields = self._get_user_allowed_fields()
        for allowed_field in allowed_fields:
            field = fields[allowed_field.name]

            # subfields are NestedModelSerializer
            if isinstance(field, ModelPermissionsSerializer):
                # no rights on subfield's fields
                # calculate how the relation should be retrieved
                if not field.get_fields():
                    field_cls = field._related_class
                    kwargs = get_relation_kwargs(allowed_field.name,
                                                 field.info)
                    if not issubclass(field_cls,
                                      serializers.HyperlinkedRelatedField):
                        kwargs.pop('view_name', None)
                    field = field_cls(**kwargs)

            ret[allowed_field.name] = field
        return ret
436315
def get_model_queries(self, query_obj, model_queries_config):
        """"""
        for search4, model_attrib in model_queries_config:

            if search4 is not None:
                query_obj = self._model_query(query_obj, search4, model_attrib)
        return query_obj
1171348
function createLogger(logger) {
    var result = logger ? objectAssign({}, logger) : {};
    if (!result.debug) result.debug = console.log;
    if (!result.info) result.info = console.info;
    if (!result.warn) result.warn = console.warn;
    if (!result.error) result.error = console.error;
    return result;
}
313232
def get_logging_fields(self, model):
        
        rel_name = '_%s_audit_log_entry'%model._meta.object_name.lower()


        def entry_instance_to_unicode(log_entry):
            try:
                result = '%s: %s %s at %s'%(model._meta.object_name,
                                                log_entry.object_state,
                                                log_entry.get_action_type_display().lower(),
                                                log_entry.action_date,

                                                )
            except AttributeError:
                result = '%s %s at %s'%(model._meta.object_name,
                                                log_entry.get_action_type_display().lower(),
                                                log_entry.action_date

                                                )
            return result

        action_user_field = LastUserField(related_name = rel_name, editable = False)

        #check if the manager has been attached to auth user model
        if [model._meta.app_label, model.__name__] == getattr(settings, 'AUTH_USER_MODEL', 'auth.User').split("."):
            action_user_field = LastUserField(related_name = rel_name, editable = False, to = 'self')

        return {
            'action_id' : models.AutoField(primary_key = True),
            'action_date' : models.DateTimeField(default = datetime_now, editable = False, blank=False),
            'action_user' : action_user_field,
            'action_type' : models.CharField(max_length = 1, editable = False, choices = (
                ('I', _('Created')),
                ('U', _('Changed')),
                ('D', _('Deleted')),
            )),
            'object_state' : LogEntryObjectDescriptor(model),
            '__unicode__' : entry_instance_to_unicode,
        }
713685
def get_direct_fields_from_model(model_class):
    
    direct_fields = []
    all_fields_names = _get_all_field_names(model_class)
    for field_name in all_fields_names:
        field, model, direct, m2m = _get_field_by_name(model_class, field_name)
        if direct and not m2m and not _get_remote_field(field):
            direct_fields += [field]
    return direct_fields
244449
public AnimaQuery<T> where(T model) {
        Field[] declaredFields = model.getClass().getDeclaredFields();
        for (Field declaredField : declaredFields) {

            Object value = AnimaUtils.invokeMethod(model, getGetterName(declaredField.getName()), AnimaUtils.EMPTY_ARG);
            if (null == value) {
                continue;
            }
            if (declaredField.getType().equals(String.class) && AnimaUtils.isEmpty(value.toString())) {
                continue;
            }
            String columnName = AnimaCache.getColumnName(declaredField);
            this.where(columnName, value);
        }
        return this;
    }
276523
def get_field_info(model):
    
    # Deal with the primary key.
    if issubclass(model, mongoengine.EmbeddedDocument):
        pk = None
    else:
        pk = model._fields[model._meta['id_field']]

    # Deal with regular fields.
    fields = OrderedDict()

    # Deal with forward relationships.
    # Pass forward relations since there is no relations on mongodb
    references = OrderedDict()

    embedded = OrderedDict()

    def add_field(name, field):
        if isinstance(field, REFERENCING_FIELD_TYPES):
            references[name] = get_relation_info(field)
        elif isinstance(field, EMBEDDING_FIELD_TYPES):
            embedded[name] = get_relation_info(field)
        elif isinstance(field, COMPOUND_FIELD_TYPES):
            fields[name] = field
            if field.field:
                add_field(name + '.child', field.field)
        elif field is pk:
            return
        else:
            fields[name] = field

    for field_name in model._fields_ordered:
        add_field(field_name, model._fields[field_name])

    # Shortcut that merges both regular fields and the pk,
    # for simplifying regular field lookup.
    fields_and_pk = OrderedDict()
    fields_and_pk['pk'] = pk
    fields_and_pk[getattr(pk, 'name', 'pk')] = pk
    fields_and_pk.update(fields)

    return FieldInfo(pk,
                     fields,
                     references,
                     fields_and_pk,
                     embedded)
873151
def get_model_field(schema, field):
    
    if schema._declared_fields.get(field) is None:
        raise Exception("{} has no attribute {}".format(schema.__name__, field))

    if schema._declared_fields[field].attribute is not None:
        return schema._declared_fields[field].attribute
    return field
1136893
def query(self, model):
        '''
        '''
        session = self.router.session()
        fields = tuple((f.name for f in model._meta.scalarfields
                        if f.type == 'text'))
        qs = session.query(model).load_only(*fields)
        for related in self.get_related_fields(model):
            qs = qs.load_related(related)
        return qs
650395
@SuppressWarnings("resource")
    public static List<Logger> getAllLoggers() {

        LoggerContext context = (LoggerContext)(LogManager.getContext(false));
        Map<String, Logger> loggersByName = new TreeMap<String, Logger>();
        for (Logger logger : context.getLoggers()) {
            String loggerName = logger.getName();
            while (loggerName != null) {
                if (!loggersByName.containsKey(loggerName)) {
                    Logger currentLogger = (Logger)(LogManager.getLogger(loggerName));
                    loggersByName.put(loggerName, currentLogger);
                }
                loggerName = getParentLoggerName(loggerName);

            }
        }
        return new ArrayList<Logger>(loggersByName.values());

    }
506494
def _get_all_field_names(model):
    
    return list(set(chain.from_iterable(
        (field.name, field.attname) if hasattr(field, 'attname') else (field.name,)
        for field in model._meta.get_fields()
        # For complete backwards compatibility, you may want to exclude
        # GenericForeignKey from the results.
        if not (field.many_to_one and field.related_model is None)
    )))
154621
function(model, options) {
      if (!(model instanceof Parse.Object)) {
        var attrs = model;
        options.collection = this;
        model = new this.model(attrs, options);
        if (!model._validate(model.attributes, options)) {
          model = false;
        }
      } else if (!model.collection) {
        model.collection = this;
      }
      return model;
    }