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 init
command. - Download metadata of the northwind service as a
.edmx
file anywhere in your system. - Import the metadata using
cds import [filepath.edmx]
. This creates a.csn
and a.edmx
file in/src/external
folder. It also creates a cds.requires entry for the Northwind service inpackage.json
. - Create the
catalog-service.cds
andcatalog-service.js
files in/src
folder 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.cds
file in/db
folder to expose the Products entity for data creation. - Create and Deploy the data model to a persistent DB as mentioned here. This creates a
.db
file inroot
. It also creates a cds.requires entry for the SQLite db inpackage.json
. - Modify the
catalog-service.js
file to add the DB insert statements. - Open a new terminal and run
cds watch
.