cds-typer
cds-typer copied to clipboard
feat: add static property `elements` to entity classes
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");