@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
41 lines • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Filter = void 0;
exports.isFilter = isFilter;
/**
* Represents a filter expression to narrow the data on a {@link GetAllRequestBuilderBase | GetAllRequestBuilder} request for multiple entities that match the specified criteria.
* A filter refers to the field of an entity and restricts the request based on an operator and a value. `Entity.FIELD_NAME.operator(value)`.
* @example `Product.NAME.equals('cloud-sdk')` creates a filter for the entity `Product` that matches in case the field `NAME` equals 'cloud-sdk'.
*
* See also: {@link Filterable}.
* @typeParam EntityT - Type of the entity to be filtered on.
* @typeParam FieldT - Type of the field to be filtered by.
*/
class Filter {
/**
* Creates an instance of Filter.
* @param field - Name of the field of the entity to be filtered on or a filter function.
* @param operator - Function to be used for matching.
* @param value - Value to be used by the operator.
* @param edmType - EDM type of the field to filter on, needed for custom fields.
*/
constructor(field, operator, value, edmType) {
this.field = field;
this.operator = operator;
this.value = value;
this.edmType = edmType;
}
}
exports.Filter = Filter;
/**
* Type guard for the `Filter` class.
* @param filterable - Object to be checked.
* @returns Whether the given object is of type `Filter`.
* @internal
*/
function isFilter(filterable) {
return (typeof filterable['field'] !== 'undefined' &&
typeof filterable['operator'] !== 'undefined' &&
typeof filterable['value'] !== 'undefined');
}
//# sourceMappingURL=filter.js.map