Filters

model. Filters

new Filters(modelDefinition, filters)

Source:

Collection class that contains filters that are to be applied when loading Model objects from the api.

Parameters:
Name Type Description
modelDefinition ModelDefinition

The ModelDefinition for which this Filters object should create filters.

filters Array.<Filter>

A list of Filter objects

Methods

(static) getFilters(modelDefinition, priorFilters) → {Filters}

Source:

Factory method to create a Filters object.

Parameters:
Name Type Description
modelDefinition ModelDefinition

The modelDefinition that the filters should apply to.

priorFilters Array.<Filter>

List of previously applied filters that the new filter list should start with.

Returns:

A Filters object for the given modelDefinition.

Type
Filters

getFilterList() → {Array.<Filter>}

Source:

Get a list of Filter objects that are in applied in this Filters instance

Returns:

The list of Filter objects.

Type
Array.<Filter>

getFilters() → {Array.<string>}

Source:
Deprecated:
  • Deprecated since 2.28, use getQueryFilterValues instead.
Returns:
Type
Array.<string>

getQueryFilterValues() → {Array.<string>}

Source:

Get an array of DHIS2 metadata filter values to send to the API.

This will return ['id:eq:UYXOT4A7JMI', 'name:like:ANC'] for filters created as follows dataElement .filter().on('id').equals(UYXOT4A7JMI) .filter().on('name').like('ANC')

Returns:

A list of query param values to be used with the filter key.

Type
Array.<string>

list() → {Promise}

Source:
Deprecated:
  • Yes
Returns:

Proxy the list() call on the filters object.

Type
Promise

logicMode(junction)

Source:
See:

The logic mode to use on the filters.

Default behavior is AND. Note that the logic will be used across all the filters, which means with OR, results will be returned when any of the filter match. It MUST be called last on the chain of filters when called through modelDefinition.filter().

Example
d2.programs.filter().on('name').like('Child')
.filter().logicMode('OR').on('code').equals('Child')
Parameters:
Name Type Description
junction string

The logic operator to use. One of ['OR', 'AND'];

on(propertyName) → {Filter}

Source:

Shortcut for triggering the creation of a Filter. This is the function that is triggered when creating new filters on a ModelDefinition. The Filter will receive a callback that can be used to add the finalized filter to the list of filters.

Parameters:
Name Type Description
propertyName string

The property that the filter should apply to. (e.g. name)

Returns:

The created filter object for propertyName.

Type
Filter