Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@sap/odata-server
Advanced tools
Library is deprecated and will not be further developed and maintained. We recommend to use the SAP Cloud application programming model to build OData Services instead of the library.
With the OData server library OData V4.0 services can be implemented based on the OASIS OData standard. The library can be directly used to build OData services and is also part of the SAP Fiori programming model as well the SAP Cloud Platform programming model, where the data model can be defined in CDS (Core data services) and the OData service be generated out of the model.
The library leaves the freedom to build OData services with any database or persistence layer. It is also possible to create services that are calling external REST/OData services and mix up the data with your application data.
The library is modular and consists of the following main components:
npm install @sap/odata-server
Load the library:
const odata = require('@sap/odata-server');
Load your EDM model:
const edmModel = require('./<your_edm_model>.json');
Create the service, set the base path, and register request handlers for CRUD operations:
const service = odata.ServiceFactory.createService(edmModel)
.setBasePath('/serviceroot.svc/')
.on('create', function create(request, response, next) {...})
.on('update', function update(request, response, next) {...})
.on('delete', function delete(request, response, next) {...})
.on('read', function read(request, response, next) {...});
You can create an HTTP server locally to test your service:
const http = require('http');
const port = 9000;
const server = http.createServer((req, res) => service.process(req, res))
.listen(port,
() => console.log('Server listens on port ' + port + ' - '
+ 'Service URL: http://localhost:' + port + '/serviceroot.svc/'));
Resource | Request |
---|---|
Service root | GET http://host/serviceRoot/ |
Metadata | GET http://host/serviceRoot/metadata |
EntitySet | GET http://host/serviceRoot/EntitySet |
EntitySet | GET http://host/serviceRoot/EntitySet/$count |
Entity | GET http://host/serviceRoot/EntitySet(Key) |
References | GET http://host/serviceRoot/EntitySet/$ref |
Reference | GET http://host/serviceRoot/EntitySet(Key)/$ref |
References (related) | GET http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToMany/$ref |
Reference (related) | GET http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToMany/$ref |
Related entity | GET http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToOne |
Related entities | GET http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToMany |
Complex property | GET http://host/serviceRoot/EntitySet(Key)/ComplexProperty |
Complex property collection | GET http://host/serviceRoot/EntitySet(Key)/ComplexPropertyCollection |
Primitive property | GET http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty |
Primitive property value | GET http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty/$value |
Primitive property collection | GET http://host/serviceRoot/EntitySet(Key)/PrimitivePropertyCollection |
Resource | Request |
---|---|
Entity | POST http://host/serviceRoot/EntitySet |
Deep insert | POST http://host/serviceRoot/EntitySet |
Entity with bind operations | POST http://host/serviceRoot/EntitySet |
Reference | POST http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToMany/$ref |
Resource | Request |
---|---|
Entity | PUT/PATCH http://host/serviceRoot/EntitySet(Key) |
Deep update | PUT/PATCH http://host/serviceRoot/EntitySet(Key) |
Reference | PUT http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToOne/$ref |
Complex property | PUT/PATCH http://host/serviceRoot/EntitySet(Key)/ComplexProperty |
Complex property collection | PUT http://host/serviceRoot/EntitySet(Key)/ComplexPropertyCollection |
Primitive property | PUT http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty |
Primitive property value | PUT http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty/$value |
Primitive property collection | PUT http://host/serviceRoot/EntitySet(Key)/PrimitivePropertyCollection |
Resource | Request |
---|---|
Entity | DELETE http://host/serviceRoot/EntitySet(Key) |
Reference | DELETE http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToOne/$ref |
Reference (to many) | DELETE http://host/serviceRoot/EntitySet(Key)/NavigationPropertyToMany(Key)/$ref |
Complex property | DELETE http://host/serviceRoot/EntitySet(Key)/ComplexProperty |
Complex property collection | DELETE http://host/serviceRoot/EntitySet(Key)/ComplexPropertyCollection |
Primitive property | DELETE http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty |
Primitive property value | DELETE http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty/$value |
Primitive property collection | DELETE http://host/serviceRoot/EntitySet(Key)/PrimitivePropertyCollection |
Resource | Request |
---|---|
Function import | GET http://host/serviceRoot/FunctionImport/[Navigation-or-Property-Path] |
boundFunction | GET http://host/serviceRoot/EntitySet/boundFunction |
boundFunction | GET http://host/serviceRoot/EntitySet(Key)/boundFunction |
boundFunction | GET http://host/serviceRoot/EntitySet(Key)/ComplexProperty/boundFunction |
boundFunction | GET http://host/serviceRoot/EntitySet(Key)/ComplexPropertyCollection/boundFunction |
boundFunction | GET http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty/boundFunction |
boundFunction | GET http://host/serviceRoot/EntitySet(Key)/PrimitivePropertyCollection/boundFunction |
Resource | Request |
---|---|
Action import | POST http://host/serviceRoot/ActionImport |
boundAction | POST http://host/serviceRoot/EntitySet/boundAction |
boundAction | POST http://host/serviceRoot/EntitySet(Key)/boundAction |
boundAction | POST http://host/serviceRoot/EntitySet(Key)/ComplexProperty/boundAction |
boundAction | POST http://host/serviceRoot/EntitySet(Key)/ComplexPropertyCollection/boundAction |
boundAction | POST http://host/serviceRoot/EntitySet(Key)/PrimitiveProperty/boundAction |
boundAction | POST http://host/serviceRoot/EntitySet(Key)/PrimitivePropertyCollection/boundAction |
System Query Option | OASIS OData V4.0 Errata 3 - Query Option Description |
---|---|
$filter | Supported values see OASIS specification |
$expand | Supported values see OASIS specification |
$select | Supported values see OASIS specification |
$orderby | Supported values see OASIS specification |
$top and $skip | Supported values see OASIS specification |
$count | Supported values see OASIS specification |
$search | Supported values see OASIS specification |
$format | Supported values see OASIS specification |
Analytical queries with $apply
are described in the
specification
for the OData data aggregration extension.
Transformation | Sample | Limitations |
---|---|---|
aggregate | GET ~/Sales?$apply=aggregate(Amount with sum as Total) | Keyword 'from' is not supported |
topcount | GET ~/Sales?$apply=topcount(2,Amount) | |
topsum | GET ~/Sales?$apply=topsum(15,Amount) | |
toppercent | GET ~/Sales?$apply=toppercent(50,Amount) | |
bottomcount | GET ~/Sales?$apply=bottomcount(2,Amount) | |
bottomsum | GET ~/Sales?$apply=bottomsum(7,Amount) | |
bottompercent | GET ~/Sales?$apply=bottompercent(50,Amount) | |
identity | GET ~/Sales?$apply=identity | |
concat | GET ~/Sales?$apply=concat(topcount(2,Amount),aggregate(Amount)) | |
groupby | GET ~/Sales?$apply=groupby((Customer/Country,Product/Name), aggregate(Amount with sum as Total)) | rollup and $all is not supported |
compute | GET ~/Customers?$apply=compute(length(Country) as Length) | |
filter | GET ~/Sales?$apply=filter(Amount gt 3) | |
orderby | GET ~/Sales?$apply=orderby(Customer/Name) | |
expand | Not supported | |
search | GET ~/Sales?$apply=search(coffee) | |
skip | GET ~/Sales?$apply=skip(5) | |
top | GET ~/Sales?$apply=top(4) |
FAQs
OData V4.0 provisioning library
The npm package @sap/odata-server receives a total of 0 weekly downloads. As such, @sap/odata-server popularity was classified as not popular.
We found that @sap/odata-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.