Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@sap/odata-server
Advanced tools
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
const odata = require('@sap/odata-server');
// Load your edm model.
const edmModel = require('./<your_edm_model>.json');
// Create the service
const service = odata.ServiceFactory.createService(edmModel)
// Register the request handler for CRUD operations
.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){...})
//Create the server
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 |
---|---|
Read Request | GET |
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 |
Create/Insert Requests | POST |
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 |
Update Requests | PUT/PATCH |
Entity | 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 |
Delete Requests | DELETE |
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 |
Actions and Functions | GET/POST |
Function import | GET http://host/serviceRoot/FunctionImports/[Navigation- or PropertyPath] |
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 |
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 |
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 |
filter | GET ~/Sales?$apply=filter(Amount gt 3) | |
expand | Not supported | |
search | GET ~/Sales?$apply=search(coffee) |
FAQs
OData V4.0 provisioning library
The npm package @sap/odata-server receives a total of 308 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.