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/cds (SAP Cloud Application Programming Model) is a framework for building enterprise-grade services and applications. It provides a comprehensive set of tools and libraries to develop, deploy, and manage data-centric applications. The package supports defining data models, services, and business logic, and it integrates seamlessly with SAP HANA and other databases.
Defining Data Models
This feature allows you to define data models using CDS (Core Data Services) and interact with them. The code sample demonstrates defining a simple data model for a bookshop and implementing a service to read book data.
const cds = require('@sap/cds');
const { entities } = cds.model;
const Books = entities('my.bookshop.Books');
module.exports = cds.service.impl(async function() {
this.on('READ', Books, async (req) => {
return [{ ID: 1, title: '1984', author: 'George Orwell' }];
});
});
Service Implementation
This feature allows you to implement services that handle CRUD operations. The code sample shows how to implement READ and CREATE operations for a 'Books' entity.
const cds = require('@sap/cds');
module.exports = cds.service.impl(async function() {
this.on('READ', 'Books', async (req) => {
return [{ ID: 1, title: '1984', author: 'George Orwell' }];
});
this.on('CREATE', 'Books', async (req) => {
const { ID, title, author } = req.data;
return { ID, title, author };
});
});
Deploying to SAP HANA
This feature allows you to deploy your CDS models and services to an SAP HANA database. The code sample demonstrates how to deploy a service to SAP HANA using the provided credentials.
const cds = require('@sap/cds');
cds.deploy('srv').to('hana', {
credentials: {
host: 'your-hana-host',
port: 'your-hana-port',
user: 'your-hana-user',
password: 'your-hana-password'
}
}).then(() => {
console.log('Deployment to SAP HANA successful');
}).catch((err) => {
console.error('Deployment failed', err);
});
LoopBack is a highly extensible Node.js framework for building APIs and connecting them with backend data sources. It provides a similar data modeling and service implementation experience as @sap/cds but is more general-purpose and not specifically tailored for SAP environments.
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It allows you to define models, perform CRUD operations, and manage database migrations. While it provides robust data modeling capabilities, it lacks the integrated service layer and SAP-specific features of @sap/cds.
TypeORM is an ORM for TypeScript and JavaScript (ES7, ES6, ES5). It supports multiple databases and provides a rich set of features for data modeling, migrations, and query building. TypeORM is more focused on database interactions and does not provide the comprehensive service layer found in @sap/cds.
The API package for the different parts of CDS. It provides access to CDS compiler, both on command line and programmatically.
Given an application with structure
db/
data-model.cds
srv/
my-service.cds
you can execute cds build
to build the models.
cds -e "cds.load('db') .then (cds.compile.to.hana)"
cds -e "cds.load('srv').then (cds.compile.to.edmx)"
See the docs for more.
FAQs
SAP Cloud Application Programming Model - CDS for Node.js
We found that @sap/cds demonstrated a healthy version release cadence and project activity because the last version was released less than 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.