databroker.Broker.add_filter

Broker.add_filter(**kwargs)[source]

Add query to the list of ‘filter’ queries.

Any query passed to db.add_filter() is stashed and “AND-ed” with all future queries.

db.add_filter(**kwargs) is just a convenient way to spell db.filters.update(**kwargs).

Examples

Filter all searches to restrict results to a specific user after a March 2017.

>>> db.add_filter(user='Dan')
>>> db.add_filter(since='2017-3')

The following query is equivalent to db(user='Dan', plan_name='scan').

>>> db(plan_name='scan')

Review current filters.

>>> db.filters
{'user': 'Dan', 'since': '2017-3'}

Clear filters.

>>> db.clear_filters()