This CAP Node.js Project is used to access an OData Service (Northwind used here), get Entity Data (Product used here) and store it in a SQLite persisted DB.
- Complete the local setup mentioned here.
- Initialize CAP project with
cds initcommand. - Download metadata of the northwind service as a
.edmxfile anywhere in your system. - Import the metadata using
cds import [filepath.edmx]. This creates a.csnand a.edmxfile in/src/externalfolder. It also creates a cds.requires entry for the Northwind service inpackage.json. - Create the
catalog-service.cdsandcatalog-service.jsfiles in/srcfolder and expose the Product entity of the Northwind service for consumption. - Add the service URL as the credentials of the cds.requires entry of the Northwind service in
package.json. - Open a new terminal and run
cds watch.
- Create
schema.cdsfile in/dbfolder to expose the Products entity for data creation. - Create and Deploy the data model to a persistent DB as mentioned here. This creates a
.dbfile inroot. It also creates a cds.requires entry for the SQLite db inpackage.json. - Modify the
catalog-service.jsfile to add the DB insert statements. - Open a new terminal and run
cds watch.