ngx-odata
Simple typescript library for generating odata queries using fluent api.
Prerequisite
Can be used as typescript\javascript library. Angular is not required.
Installation
npm
npm install ngx-odata-v4
yarn
yarn add ngx-odata-v4
Integration
- Install library
- Import Query class
import { Query } from "ngx-odata-v4";
Examples
Simple query example
Query.create .expand'Requester', o.select'Email', 'ID' .expand'Responder', o.select'Email', 'ID' .orderBy'Created', OrderBy.Desc .orderBy'Status', OrderBy.Desc;
Complex query example
Query.create .filter'Id', OperatorType.Greater, 1 .filter'ReferenceId', OperatorType.Eq, 'c8027a81-5f7a-4a24-87a4-eec9afe48751' .filterComplex`Status eq 'Pending' or Status eq 'Approved'` .filter'Name', OperatorType.NotEqual, 'qwerty'.compile;
Complex expand query example
Query.create .expand'Prop1' .expand'Prop2', .expand'Complex', .select'RootId', 'RootName'.compile
Angular usage Example
.expand'Requester', o.select'Email', 'ID' .expand'Responder', o.select'Email', 'ID' .orderBy'Created', OrderBy.Desc .orderBy'Status', OrderBy.Desc; ; this.generatedUrl = `http://localhost/PrivateKey?`; this.resp = await this.http.getthis.generatedUrl, .toPromise
GitHub
Please feel free to declare issues or contribute: https://github.com/skynet2/ngx-odata