Koncorde

Available since 1.6.0

Instantiates a new Koncorde engine.


Constructor

This class constructor takes no argument.


exists

Returns a boolean telling whether filters exist for an index-collection pair.

Arguments

Copied to clipboard!
exists(index, collection);

Arguments Type Description
index
string
Index name
collection
string
Collection name

Return

The exists function returns a boolean telling whether at least one filter exists in the provided index-collection pair.


getFilterIds

Retrieves the list of filter identifiers registered on an index-collection pair.

Arguments

Copied to clipboard!
getFilterIds(index, collection);

Arguments Type Description
index
string
Index name
collection
string
Collection name

Return

The getFilterIds function returns an array of strings, containing the exhaustive list of filter identifiers registered in the provided index-collection pair.


normalize

Available since 1.1.0

Normalizes filters without storing them.

The result can be directly used with the store function.

Arguments

Copied to clipboard!
normalize(index, collection, filters);

Arguments Type Description
index
string
Index name
collection
string
Collection name
filters
object
Filters, in Koncorde format

Return

The normalize function returns a promise resolving to an object with the following properties:

Field Type Description
collection
string
Collection name
id
string
The filter unique identifier
index
string
Index name
normalized
object[]
Normalized/optimized version of the supplied filters

register

Registers a filter to this Koncorde instance.

This method is equivalent to executing normalize + store.

Arguments

Copied to clipboard!
register(index, collection, filters);

Arguments Type Description
index
string
Index name
collection
string
Collection name
filters
object
Filters, in Koncorde format

Return

The register functions returns a promise, resolving to an object with the following attributes:

Field Type Description
id
string
The filter unique identifier
diff
object
If the filter doesn't already exist in the engine, contains the normalized version of the provided filters

remove

Removes a filter.

Arguments

Copied to clipboard!
remove(filterId);

Arguments Type Description
filterId
string
Filter unique identifier, obtained either with normalize or register

Return

The remove function returns a promise, resolved once the filter has been completely removed from Koncorde.


store

Available since 1.1.0

Stores filters, normalized with the normalize) function.

Arguments

Copied to clipboard!
store(normalized);

Arguments Type Description
normalized
object
Normalized filters

Return

The store function returns an object with the following attributes:

Field Type Description
id
string
The filter unique identifier
diff
object
If the filter didn't already exist, contains the normalized version of the provided filters

test

Tests data and returns the matching filter identifiers.

Arguments

Copied to clipboard!
test(index, collection, data, [documentId]);

Arguments Type Description
index
string
Index name
collection
string
Collection name
data
object
Data to test
documentId
string
Document unique identifier

Return

The test function returns an array of strings, which is the exhaustive list of matching filter identifiers.


validate

Validates the provided filters without storing them.

Arguments

Copied to clipboard!
validate(filters);

Arguments Type Description
filters
object
Filters, in Koncorde format

Return

The validate function returns a promise, which is resolved if the filters are well-formed, and rejected otherwise.