General representation of condition useable for data restriction.
Conditon is basically filtering rule which can be applied by the client to fetch only records matching some restriction. Conditon is always either simple (represented by a single filtering rule) or composite (represented by multiple filtering rules combined using AND/OR operators) object.
- To see how to create certain Conditon instance, please check Conditions factory methods.
- To see how to apply certain Conditon to filter records, please check Operations.read(..) method.
- Version:
- 15.4.5
- Source:
- See:
-
- Conditions.SIMPLE(..) to create Condition with a single filtering restriction.
- Conditions.OR(..) to create composite Condition which consist of multiple filtering restrictions joining them using an OR operator.
- Conditions.AND(..) to create composite Condition which consist of multiple filtering restrictions joining them using an AND operator.
- Operations.read(..) to fetch data programmatically filtered using the given Condition instance.
Methods
visit(conditionVisitor)
stable API
Interpret this Condition by the given ConditionVisitor.
Allows author of the BOP to interpret incoming Conditions and transform them into proper URL query or generally process them any way (s)he need.
Parameters:
Name | Type | Description |
---|---|---|
conditionVisitor |
bop/js/spi/operation/ConditionVisitor | ConditionVisitor to interpret this Condition |
- Version:
- 17.1.1
- Source:
- See:
Example
define([
'operation/js/api/OperationResult',
'{{package}}/js/MyConditionVisitor'
], function (
OperationResult,
MyConditionVisitor
) {
var Employee = function() {
};
Employee.find = function(operationData) {
var results = [];
var baseURL = 'http://example.com/employee';
var condition = operationData.getQuery().getCondition();
// The visitor is there to turn Condition abstraction into
// whatever shape data provider expects on it's input
var resultURL = condition.visit(new MyConditionVisitor(baseURL));
$.ajax({
url: resultURL,
type: 'GET'
}).done(function(response) {
// Because the URL was change by the visitor, we should have filtered results here
fulfil(OperationResult.success(response));
});
};
return Employee;
});