utilities/query-helper.js
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
  }
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
  }
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 }
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.
Get a list of fields that can be queried against .