OData Filter Builder
ODataFilterBuilder
is util to build
$filter part
for
OData URL query options
Documentation
ODataFilterBuilder
- logical operatorsODataFilterBuilder.filters
- canonical functions
Installation
The fastest way to get started is to serve JavaScript from the unpkg:
<!-- NOTE: See https://unpkg.com how to use specific vesion. --><!-- NOTE: not minified version - https://unpkg.com/odata-filter-builder@1.0.0-0/dist/odata-filter-builder.js -->
// now you can find the library on window.ODataFilterBuildervar f = ODataFilterBuilder;
If you'd like to use bower:
$ bower install --save https://unpkg.com/odata-filter-builder@1.0.0-0/dist/odata-filter-builder.js
And it's just as easy with npm:
$ npm install --save odata-filter-builder
// using ES6 modules;
// using CommonJS modulesvar f = ODataFilterBuilder;
Also you can try it in your browser
How to use
f([condition='and'])
Constructor for ODataFilterBuilder
class. Create new instance of filter builder.
Can be used without new
operator.
parameter | type | description |
---|---|---|
[condition='and'] |
string | optional: base condition ('and'/'or'). |
Examples
// can be used without "new" operator// default base condition is 'and' ;// (TypeId eq '1') and (contains(tolower(Name), 'a'))
// there are different constructors for 'and' as base condition// f(), f('and') and f.and() ;// (Type/Id eq 3) and (concat(concat(City, ', '), Country) eq 'Berlin, Germany')
f.or()
ODataFilterBuilder
constructor alias.
Same as f('or')
.
Creates a new OData filter builder with 'or'
as base condition.
Examples
// 'or' condition as base condition ;// (tolower(Name) eq 'foo') or (tolower(Name) eq 'bar')
// combination of 'or' and 'and' ;// ((contains(tolower(Name), 'google')) or (contains(tolower(Name), 'yandex'))) and (Type/Name eq 'Search Engine')
More examples
You can find more examples in test/ODataFilterBuilder_spec.js.
To use with AngularJS see http://stackoverflow.com/a/36128276/223750.
Build your copy
Clone repository and use npm scripts
Tests
$ npm test$ npm run test:watch$ npm run test:cov$ npm run lint
Build
$ npm run build
JSDoc
$ npm run jsdoc