https://github.com/soontao/light-odata
OData(V2/V4) Client for javascript/typescript
https://github.com/soontao/light-odata
c4c cap odata odata-client sap
Last synced: 9 months ago
JSON representation
OData(V2/V4) Client for javascript/typescript
- Host: GitHub
- URL: https://github.com/soontao/light-odata
- Owner: Soontao
- License: mit
- Created: 2018-02-13T09:49:02.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-27T05:24:55.000Z (about 1 year ago)
- Last Synced: 2025-03-27T06:26:11.351Z (about 1 year ago)
- Topics: c4c, cap, odata, odata-client, sap
- Language: TypeScript
- Homepage:
- Size: 4.19 MB
- Stars: 43
- Watchers: 2
- Forks: 11
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# OData Client
[](https://www.npmjs.com/package/@odata/client)


[](https://github.com/Soontao/light-odata/actions/workflows/nodejs.yml)
[](https://codecov.io/gh/Soontao/light-odata)


[](https://sonarcloud.io/dashboard?id=Soontao_c4codata)
[](https://sonarcloud.io/dashboard?id=Soontao_c4codata)
[](https://deepscan.io/dashboard#view=project&tid=9408&pid=11929&bid=178297)
Javascript OData Client for OData (v2/v4) Service.
## Installation
```bash
npm i -S @odata/client
```
Alternative, in native browser environment, just add [unpkg](https://unpkg.com/@odata/client) or [jsdeliver](https://www.jsdelivr.com/package/npm/@odata/client) umd link to your page, and the `OData` object will be available in `window`.
```html
```
## ODataClient
> How to use `@odata/client`
Start with a simple query, following code start a `GET` http request, and asks the server to respond to all customers which phone number equals 030-0074321
```javascript
import { OData } from "@odata/client"
// import "@odata/client/lib/polyfill" // server side polyfill
// odata.org sample odata service
const serviceEndpoint = "https://services.odata.org/V2/Northwind/Northwind.svc/"
const client = OData.New({ serviceEndpoint })
const runner = async () => {
// Query by filter
//
// GET /Customers?$format=json&$filter=Phone eq '030-0074321'
const filter = client.newFilter().property("Phone").eq("030-0074321");
// just an example, suggest to use the EntitySet API
const result = await client.newRequest({ // ODataRequest object
collection: "Customers", // entity set
params: client.newParam().filter(filter) // odata param
})
}
```
```js
// OData V4 client
const client = OData.New4({ serviceEndpoint: "https://odata-v4-demo-001.herokuapp.com/odata/" })
```
## SystemQueryOption
use `SystemQueryOption` to control `response size`, `element projection` and `order`
[go to the document](./docs/API.SystemQueryOptions.md)
## ODataFilter
use the `ODataFilter` to filter data
[go to the document](./docs/API.ODataFilter.md)
## EntitySet
use `EntitySet` to perform `CRUD` on a specific entity
[go to the document](./docs/API.EntitySet.md)
## Batch requests
use odata `$batch` api for operating multi entities in **single** HTTP request, it will save a lot of time between client & server (In the case of processing a large number of requests).
[go to the document](./docs/Batch.md)
## Advanced
some advanced topics
- literal in uri
- request interpreter
- server side polyfill
[go to the document](./docs/Advanced.md)
## [CHANGELOG](./CHANGELOG.md)
## [LICENSE](./LICENSE)
## Thanks JetBrains
[](https://www.jetbrains.com/?from=light-odata)