cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Dear CAP Community,

I am trying to experiment with the cds repl using the famous bookshop demo example rolled out by SAP.

I have set up the Visual Studio code and installed all the necessary node modules like @sap/cds-dk along with installation of npm and nodejs. After launcing the cds repl using cds r and instantiating the cds facade object using -> const cds = require('@sap/cds').connect('db') in the repl, I am trying to call cds.entities, but I don't get the list of entities defined - Books, Authors, Orders. It is coming blank, do we know why?

Best Regards,

Tanmoy

View Entire Topic
martinstenzig
Contributor
0 Likes

The way you are calling it, you don't have anything started in your cds environment. You can

1. Start a debugging session and place a breakpoint into an event handler to use the cds repl functionality in the debugger or

2. You can use the following commands (after you do 'cds r') to bootstrap the basic sql lite in memory db and load your model into it

cds.env.add ({ requires: { db: { kind:'sqlite', ...cds.env.requires.kinds.sqlite, credentials: cds.env.requires.db?.credentials?.url ? {url:':memory:'} : {database:':memory:'}}}})

cds.db = await cds.connect.to ('db')

const m = await cds.load('*',{}) .then (cds.minify)

await cds.deploy(m).to(cds.db,{})

for (let e of cds.db.entities) { console.log(e.kind,e.name)}