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
patricebender
Product and Topic Expert
Product and Topic Expert
0 Likes

You have to bootstrap your bookshop within your repl session:

❯ cds r
Welcome to cds repl v 7.5.0
> var server = cds.test() // ⬅️ Bootstrap works like this if you started repls within the booskhop dir
> [cds] - loaded model from 5 file(s):

  srv/user-service.cds
  srv/cat-service.cds
  srv/admin-service.cds
  db/schema.cds
  ../../../cds/common.cds

[cds] - connect to db > sqlite { url: ':memory:' }
  > init from db/init.js


…


> { Genres } = cds.entities()
(ns) => !ns ? children : this.childrenOf (ns,filter)
> Genres.elements
{
  name: string {
    '@title': '{i18n>Name}',
    localized: true,
    type: 'cds.String',
    length: 255,
    '@Common.Label': '{i18n>Name}'
  },
  descr: string {
    '@title': '{i18n>Description}',
    localized: true,
    type: 'cds.String',
    length: 1000,
    '@Common.Label': '{i18n>Description}'
  },
  ID: number { key: true, type: 'cds.Integer' },
  parent: Association {
    type: 'cds.Association',
    target: 'sap.capire.bookshop.Genres',
    keys: [ { ref: [ 'ID' ], '$generatedFieldName': 'parent_ID' } ]
  },
  parent_ID: number { type: 'cds.Integer', '@odata.foreignKey4': 'parent' },
  children: Composition {
    type: 'cds.Composition',
    cardinality: { max: '*' },
    target: 'sap.capire.bookshop.Genres',
    on: [ { ref: [ 'children', 'parent' ] }, '=', { ref: [ '$self' ] } ]
  },
  texts: Composition {
    type: 'cds.Composition',
    cardinality: { max: '*' },
    target: 'sap.capire.bookshop.Genres.texts',
    on: [ { ref: [ 'texts', 'ID' ] }, '=', { ref: [ 'ID' ] } ]
  },
  localized: Association {
    type: 'cds.Association',
    target: 'sap.capire.bookshop.Genres.texts',
    on: [
      { ref: [ 'localized', 'ID' ] },
      '=',
      { ref: [ 'ID' ] },
      'and',
      { ref: [ 'localized', 'locale' ] },
      '=',
      { ref: [ '$user', 'locale' ] }
    ]
  }
}