src/resource_filter.js
function Filter(opts) {
  this.model = opts.model

  this.filteredKeys = isPlainObject(opts.filteredKeys)
    ? {
        private: opts.filteredKeys.private || [],
        protected: opts.filteredKeys.protected || []
      }
    : {
        private: [],
        protected: []
      }

  if (this.model && this.model.discriminators && isPlainObject(opts.excludedMap)) {
    for (const modelName in this.model.discriminators) {
      if (opts.excludedMap[modelName]) {
        this.filteredKeys.private = this.filteredKeys.private.concat(opts.excludedMap[modelName].private)
        this.filteredKeys.protected = this.filteredKeys.protected.concat(opts.excludedMap[modelName].protected)
      }
    }
  }
}
function Filter(opts) {
  this.model = opts.model

  this.filteredKeys = isPlainObject(opts.filteredKeys)
    ? {
        private: opts.filteredKeys.private || [],
        protected: opts.filteredKeys.protected || []
      }
    : {
        private: [],
        protected: []
      }

  if (this.model && this.model.discriminators && isPlainObject(opts.excludedMap)) {
    for (const modelName in this.model.discriminators) {
      if (opts.excludedMap[modelName]) {
        this.filteredKeys.private = this.filteredKeys.private.concat(opts.excludedMap[modelName].private)
        this.filteredKeys.protected = this.filteredKeys.protected.concat(opts.excludedMap[modelName].protected)
      }
    }
  }
}
function Filter ( opts ) { this . model = opts . model this . filteredKeys = isPlainObject ( opts . filteredKeys ) ? { private : opts . filteredKeys . private || [ ] , protected : opts . filteredKeys . protected || [ ] } : { private : [ ] , protected : [ ] } if ( this . model && this . model . discriminators && isPlainObject ( opts . excludedMap ) ) { for ( const modelName in this . model . discriminators ) { if ( opts . excludedMap [ modelName ] ) { this . filteredKeys . private = this . filteredKeys . private . concat ( opts . excludedMap [ modelName ] . private ) this . filteredKeys . protected = this . filteredKeys . protected . concat ( opts . excludedMap [ modelName ] . protected ) } } } }
Represents a filter.
@constructor
@param {Object} opts - Options
@param {Object} opts.model - Mongoose model
@param {Object} opts.excludedMap {} - Filtered keys for related models
@param {Object} opts.filteredKeys {} - Keys to filter for the current model
Represents a filter .