What is @sap/cds-compiler?
@sap/cds-compiler is a package designed to compile and process Core Data Services (CDS) models. It is part of the SAP Cloud Application Programming Model (CAP) and provides functionalities to parse, compile, and transform CDS models into various formats.
What are @sap/cds-compiler's main functionalities?
Parsing CDS Models
This feature allows you to parse CDS source code into a Core Schema Notation (CSN) model. The code sample demonstrates how to parse a simple CDS model defining an entity 'Books' with a 'title' property.
const cds = require('@sap/cds-compiler');
const source = 'entity Books { title: String; }';
const csn = cds.parse(source);
console.log(JSON.stringify(csn, null, 2));
Compiling CDS Models
This feature allows you to compile CDS source code into a CSN model. The code sample shows how to compile a CDS model into its CSN representation.
const cds = require('@sap/cds-compiler');
const source = 'entity Books { title: String; }';
const csn = cds.compile.to.csn(source);
console.log(JSON.stringify(csn, null, 2));
Transforming CDS Models
This feature allows you to transform CDS models into different formats, such as EDM (Entity Data Model). The code sample demonstrates transforming a CSN model into an EDM format.
const cds = require('@sap/cds-compiler');
const source = 'entity Books { title: String; }';
const csn = cds.compile.to.csn(source);
const edm = cds.compile.to.edm(csn);
console.log(JSON.stringify(edm, null, 2));
Other packages similar to @sap/cds-compiler
sequelize
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It provides functionalities to define models and interact with databases. While it does not compile CDS models, it offers similar functionalities for defining and working with data models.