Skip to content

Documentation appears to be outdated for cds.model #2433

@dinurp

Description

@dinurp

Property: cds.model from doc-github states the following code fragment is what is used in server.js for assigning the property cds.model.

cds.model = await cds.load('*')

With the recent updates, observed in v 9.7, this cannot be the case; cds.load returns csn which does not have a property entities. So, this assignment will not be compatible with the definition of the property cds.entities; it would be undefined after this assignment. At the minimum, for type compatibility, this has to be

cds.model = await cds.load('*').then(cds.compile.for.nodejs)

Log in cds.repl with samples project

Welcome to cds repl v 9.7.1
> cds.model = await cds.load("*")
> typeof(cds.entities)
undefined
> cds.model = await cds.load("*").then(cds.compile.for.nodejs)
> typeof(cds.entities)
function
> cds.entities("sap.capire.bookshop").Books.kind
entity

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions