cancel
Showing results for 
Search instead for 
Did you mean: 

Missing entities in db.entities

martin_voros
Active Contributor
0 Kudos

Hi,

there seems to some entities when I split my definition of entities into multiple file. As the schema.cds was getting too big, I decided to split my definitions into multiple files. E.g. I have two files (base.cds and schema.cds) in /db and each file has its own namespace. I noticed that when I do stuff like

const { MyEntity } = db.entities

I can only get entities that are defined in the first file. In this case, it's only entities from base.cds. As a test I also added additional file a.cds with one test entity. In that case, only test entity was available.

Is this a bug? Or how can I achieve that I have definitions split across multiple files but they all get loaded into variable db.entities.

Accepted Solutions (1)

Accepted Solutions (1)

johannesvogel
Advisor
Advisor
0 Kudos

Hi Martin,

you can create a e. g. index.cds file that combines all other .cds files using the "using from" syntax (https://cap.cloud.sap/docs/cds/cdl#using). You can also omit the namespace to import all definitions of the file e. g. using from '....'.

Please also make sure to use this newly created file as .model property in the connect options of your db (https://cap.cloud.sap/docs/node.js/api#cds-connect-options).

Best regards,

Johannes

martin_voros
Active Contributor
0 Kudos

Thanks, this works fine. I missed that you can define a main file in package.json.

Answers (0)