tacker.objects.common module

tacker.objects.common.apply_filters(query, filters)

Apply filters to a SQLAlchemy query.

Parameters:
  • query – The query object to which we apply filters.

  • filters – A dict or an iterable of dicts, where each one includes the necesary information to create a filter to be applied to the query. There are single query filters, such as filters = {‘model’: ‘Foo’, ‘field’: ‘name’, ‘op’: ‘==’, ‘value’: ‘foo’}. And multiple query filters, such as filters = {‘and’: [ {‘field’: ‘name’, ‘model’: ‘Foo’, ‘value’: ‘foo’, ‘op’: ‘==’}, {‘field’: ‘id’, ‘model’: ‘Bar’, ‘value’: ‘bar’, ‘op’: ‘==’} ]}