cds-typer icon indicating copy to clipboard operation
cds-typer copied to clipboard

feat: add static property `elements` to entity classes

Open stockbal opened this issue 4 months ago • 0 comments

Enables proper access to all entity elements of the underlying LinkedDefinition.

e.g.

entity Books : cuid {
  title : String;
  stock : Integer;
}

new property elements allows access to all defined elements of the entity and access the underlying LinkedDefinition of those elements.

import { Book } from "#cds-models/my/bookshop";
import cds from "@sap/cds";

if (Book.elements.ID instanceof cds.builtin.classes.UUID) console.log("ID is of type UUID");
if (Book.elements.stock instanceof cds.builtin.classes.Integer) console.log("stock is of type Integer");

stockbal avatar Oct 04 '24 10:10 stockbal