Retrieves a value from the JSON database

@param {Key|Key[]|Object|true} filter Filter to use to find values to
retrieve. If true, all will be deleted

@returns {Key[]} An array containing the keys of the deleted data.
514331
function doDelete(filter) {
    console.log('doDelete', filter);
    return new Promise(function(resolve, reject) {
      var i, keysPromise, dataPromise;

      if (filter === true) {
        // Delete all
        if (options.cacheKeys) {
          keysPromise = Promise.resolve(cachedKeys);
        } else {
          keysPromise = readKeys();
        }

        keysPromise.then(function(existingKeys) {
          console.log('delete got existing keys', existingKeys);
          if (options.cacheValues) {
            cachedData = {};
          }
          if (options.cacheKeys) {
            cachedKeys = [];
          }

          saveData({}).then(function() {
            resolve(existingKeys);
          });
        }).catch(function(error) {
          reject(error);
        });

        return;
      } else if (common.keyTypes.indexOf(typeof filter) !== -1) {
        filter = [filter];
      } else if (filter instanceof Array) {
      } else if (typeof filter === 'object') {
        // Determine execution path for filter
        if (options.cacheValues) {
          dataPromise = Promise.resolve(cachedData);
        } else {
          dataPromise = readData();
        }

        dataPromise.then(function(data) {
          var deletedKeys = [];
          return common.processFilter(data, filter, function(id) {
            deletedKeys.push(id);
            delete data[id];
          }).then(function() {
            return saveData(data);
          }).then(function() {
            resolve(deletedKeys);
          });
        }).catch(function(error) {
          reject(error);
        });

        return;
      } else {
        reject({
          message: 'filter needs to be an object containing a filter'
        });
        return;
      }

      /* Check if we need to load the values key checking if the keys are
       *   actually in the database */
      if (!options.cacheValues && options.cacheKeys) {
        var haveKey = false;
        for (i in filter) {
          if(cachedKeys.indexOf(filter[i]) !== -1) {
            haveKey = true;
            break;
          }
        }
        if (haveKey) {
          dataPromise = readData();
        } else {
          resolve([]);
          return;
        }
      } else if (options.cacheValues) {
        dataPromise = Promise.resolve(cachedData);
      } else {
        dataPromise = readData();
      }

      dataPromise.then(function(data) {
        var deletedIds = [];
        // Go through and delete
        filter.forEach(function(id) {
          if (data[id] !== undefined) {
            delete data[id];
            deletedIds.push(id);
          }
        });

        return saveData(data).then(function() {
          resolve(deletedIds);
          return Promise.resolve();
        });
      }).catch(function(error) {
        reject(error);
      });
    });

  }
1154265
function arrayFilter (obj, iterate, context) {
  var result = []
  if (obj && iterate) {
    context = context || this
    if (obj.filter) {
      return obj.filter(iterate, context)
    }
    baseExports.each(obj, function (val, key) {
      if (iterate.call(context, val, key, obj)) {
        result.push(val)
      }
    })
  }
  return result
}
1169539
public static cacheselector[] get_filtered(nitro_service service, String filter) throws Exception{
		cacheselector obj = new cacheselector();
		options option = new options();
		option.set_filter(filter);
		cacheselector[] response = (cacheselector[]) obj.getfiltered(service, option);
		return response;
	}
264098
def filters(self):
        
        results = []
        filters = self.qs.get('filter')
        if filters is not None:
            try:
                results.extend(json.loads(filters))
            except (ValueError, TypeError):
                raise InvalidFilters("Parse error")
        if self._get_key_values('filter['):
            results.extend(self._simple_filters(self._get_key_values('filter[')))
        return results
194624
public function toArray(
        array $columns = [],
        $filter = null
    ): array {
        $data = [];
        foreach ($this as $key => $item) {
            $data[$key] = $item;
        }
        unset($data['_keyMap']);
        if (!empty($this->_keyMap)) {
            foreach ($this->_keyMap as $beanKey => $dataKey) {
                if (array_key_exists($beanKey, $data)) {
                    $data[$dataKey] = $data[$beanKey];
                    unset($data[$beanKey]);
                }
            }
        }

        empty($columns) || $data = array_intersect_key(
            $data,
            array_flip($columns)
        );
        if ($filter === static::FILTER_NOT_NULL) {
            return array_filter($data, function ($val) {
                return !is_null($val);
            });
        } else if ($filter === static::FILTER_NOT_EMPTY) {
            return array_filter($data, function ($val) {
                if ($val === 0 || $val === '0') {
                    return true;
                } else {
                    return !empty($val);
                }
            });
        } else if (is_callable($filter)) {
            return array_filter($data, $filter);
        }
        return $data;
    }
250054
public static service[] get_filtered(nitro_service service, String filter) throws Exception{
		service obj = new service();
		options option = new options();
		option.set_filter(filter);
		service[] response = (service[]) obj.getfiltered(service, option);
		return response;
	}
754976
public static filterpolicy[] get_filtered(nitro_service service, String filter) throws Exception{
		filterpolicy obj = new filterpolicy();
		options option = new options();
		option.set_filter(filter);
		filterpolicy[] response = (filterpolicy[]) obj.getfiltered(service, option);
		return response;
	}
1093648
function _get_selected_items(){
	
	var ret_filters = [];

	// Push out the filters that have selected == true.
	var all_filters = _get_all_items();
	for( var afi = 0; afi < all_filters.length; afi++ ){
	    var filter_name = all_filters[afi];
	    var fconf = anchor.current_data[filter_name];
	    if( fconf &&
		typeof fconf['selected'] != 'undefined' &&
		fconf['selected'] == true ){
		    ret_filters.push(filter_name);
		}
	}

	return ret_filters;
    }
357870
public static fis[] get_filtered(nitro_service service, String filter) throws Exception{
		fis obj = new fis();
		options option = new options();
		option.set_filter(filter);
		fis[] response = (fis[]) obj.getfiltered(service, option);
		return response;
	}
1185691
public static function fieldsKey($table, $filter="id") {

        try {
            $row = (array) self::findRow("select * from ".$table, "assoc");
            // remove array element base on filter if _none_ no filter
            if (strtolower($filter)!="_none_") {
                // default is to filter id field
                unset($row[$filter]);
            }
            return array_keys($row);
        } catch (Exception $e) {
            echo $e->getTraceAsString();
        }        
    }
1132247
function (filter) {
    var obj = {}
    var val = this.__input

    this.each(function (property, key) {
      obj[key] = property.flatten ? property.flatten(filter) : property
    }, wrapFilter(filter))

    if (val !== void 0) {
      if (val instanceof Base) {
        val = {
          reference: val.path
        }
      }
      obj.val = val
    }

    // refactoring non standard keys
    var flattened = flatten(obj)
    for (var key in flattened) {
      if (key.indexOf('.val') > 0) {
        var newKey = key.split('.val')[0]
        flattened[newKey] = flattened[key]
        delete flattened[key]
      }
    }
    return flattened
  }
255036
def parse_filter(filter)
      filter.is_a?(Hash) ? URI.encode(filter.to_json) : filter
    end
156582
function collectionDelete(filter) {

        if ( typeof(filter) !== 'object' ) {
            throw new Error('filter must be an object');
        } else {
            var content     = JSON.parse(JSON.stringify( collections[ this['_collection'] ] ))
                //, condition = filter.count()
                , i         = 0
                , found     = [];

            for (var o in content) {
                for (var f in filter) {
                    if ( filter[f] && keywords.indexOf(filter[f].toLocaleLowerCase()) > -1 && filter[f].toLowerCase() == 'not null' && typeof(content[o][f]) != 'undefined' && typeof(content[o][f]) !== 'object' && content[o][f] != 'null' && content[o][f] != 'undefined' ) {
                        if (found.indexOf(content[o][f]) < 0 ) {
                            found[i] = content[o][f];
                            delete collections[ this['_collection'] ][o][f];
                            ++i
                        }

                    } else if ( typeof(content[o][f]) != 'undefined' && typeof(content[o][f]) !== 'object' && content[o][f] === filter[f] ) {
                        found[i] = content[o];
                        collections[ this['_collection'] ].splice(o, 1);
                        ++i
                    }
                }
            }
        }

        if (found.length > 0 ) {
            storage.setItem(this['_bucket'], JSON.stringify(collections));
            return true
        }

        return false
    }
250319
protected function filterOutArrayValues($values = null, \Closure $filter = null, $preserveKeys = false)
    {
        $data = [];

        if (is_array($values) && count($values))
        {
            foreach ($values as $key => $value)
            {
                $value = trim($value);

                if (!empty($value))
                {
                    if (is_callable($filter) && $filter($value))
                    {
                        $data[$key] = $value;
                    }
                }
            }

            if (!$preserveKeys)
            {
                $data = array_values($data);
            }
        }

        return $data;
    }
1067968
function runFilter(data, filter) {
  var k, key, keys = Object.keys(filter), keysLength = keys.length;
  var i;

  if (!Object.keys(filter).length) {
    return true;
  }

  keyCheck: for (k = 0; k < keysLength; k++) {
    key = keys[k];

    // Match
    if (key.startsWith('$')) {
      //if (key.startsWith(
      switch (key) {
        case '$or':
          for (i = 0; i < filter[key].length; i++) {
            if (runFilter(data, filter[key][i])) {
              continue keyCheck;
            }
          }
          return false;
        case '$and':
          for (i = 0; i < filter[key].length; i++) {
            if (!runFilter(data, filter[key][i])) {
              return false;
            }
          }
          break;
        case '$not':
          if(runFilter(data, filter[key])) {
            return false;
          }
          break;
      }
    } else if (typeof data === 'object') {
      if (typeof filter[key] === 'object') {
        if (Object.keys(filter[key]).find(function(operator) {
          switch (operator) {
            case '$eq':
              if (data[key] instanceof Array) {
                return data[key].indexOf(filter[key]['$eq']) === -1;
              } else {
                return !data[key] || data[key] !== filter[key]['$eq'];
              }
            case '$ne':
              if (data[key] instanceof Array) {
                return data[key].indexOf(filter[key]['$ne']) !== -1;
              } else {
                return data[key] === filter[key]['$ne'];
              }
            case '$gt':
              return !data[key] || data[key] <= filter[key]['$gt'];
            case '$gte':
              return !data[key] || data[key] < filter[key]['$gte'];
            case '$lt':
              return !data[key] || data[key] >= filter[key]['$lt'];
            case '$lte':
              return !data[key] || data[key] > filter[key]['$lte'];
            case '$in':
              if (!filter[key]['$in'] instanceof Array) {
                throw new Error('$in test values should be an array');
              }

              return filter[key]['$in'].indexOf(data[key]) === -1;
            case '$nin':
              if (!filter[key]['$nin'] instanceof Array) {
                throw new Error('$in test values should be an array');
              }

              return filter[key]['$nin'].indexOf(data[key]) !== -1;
            default:
              throw new Error('Unknown operator ' + operator);
          }
        })) {
          return false;
        }
      } else if (!((data[key] instanceof Array
          && data[key].indexOf(filter[key]) !== -1)
          || data[key] === filter[key])) {
        return false;
      }
    } else {
      return false;
    }
  }

  return true;
  // TODO Handle logical operators
}
897788
function(filter, choice) {
      var choices = [];
      for (var i = 0; i < filter.choices.length; i++) {
        choices.push({
          label: filter.choices[i].label,
          action: filter.name,
          value: filterValueToChoiceValue(filter.choices[i].value, choice),
          default: filter.choices[i].value === filter.def
        });
      };
      return choices;
    }
78218
public static <T> Collection<T> filter(Collection<T> data, Filter<T> filter) {
        if (!Utils.isEmpty(data)) {
            Iterator<T> iterator = data.iterator();
            while (iterator.hasNext()) {
                T item = iterator.next();
                if (!filter.accept(item)) {
                    iterator.remove();
                }
            }
        }
        return data;
    }