Common Contacts Sample
This sample provides a reuse package with common domain models and services for contacts-related data.
Usage
Import to your project
npm install @sap/capire-contacts
e.g. see: bookstore
Reusing aspects
Define own entities derived from the pre-defined aspects as in bookstore:
using { sap.capire.contacts.Person } from '@sap/capire-contacts';
entity Authors : contacts.Person { ... }
Note: All entities in this package are annotated with
@cds.persistence.skip:'if-unused', so they will be ignored if not referred to from other entities in your models.
Reusing entities
Reuse the entities as in this example from users-service:
using { sap.capire.contacts.Contacts } from '@sap/capire-contacts';
service UsersService @(requires:'authenticated-user') {
entity MyProfile as select from Contacts where ID=$user;
...
}
Reusing code lists
Reuse the code lists as in ./tests/index.cds:
service Sue { ...
// expose Countries to activate provided code lists
@readonly entity Countries as projection on sap.capire.contacts.Countries;
}
Reuse code list service
const { intercept } = require ('@sap/capire-contacts/srv/code-lists')
Content
Concepts
- Reuse of packages
- Code Lists,
@sap/cds/commonand@cds.persistence.skip: 'if-unused' - Using
aspectsvsentities