.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using { Currency, managed, sap } from '@sap/cds/common';
|
||||
using { Currency, managed, temporal, sap } from '@sap/cds/common';
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
entity Books : managed {
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
service AdminService @(requires:'admin') {
|
||||
entity Books as projection on my.Books;
|
||||
|
||||
entity Books as SELECT from my.Books { *,
|
||||
// key ID, key validFrom
|
||||
};
|
||||
entity Authors as projection on my.Authors;
|
||||
|
||||
// @cds.redirection.target:false
|
||||
// entity Books.history @(cds.temporal:false) as projection on Books {
|
||||
// *,
|
||||
// key ID,
|
||||
// key validFrom @(cds.valid.from:false),
|
||||
// validTo @(cds.valid.to:false),
|
||||
// };
|
||||
}
|
||||
|
||||
// entity NonTemporalBook as projection on my.Books {
|
||||
// *,
|
||||
// key ID,
|
||||
// key validFrom @(cds.valid.from:false),
|
||||
// validTo @(cds.valid.to:false),
|
||||
// };
|
||||
|
||||
extend my.Books with {
|
||||
history : Composition of many my.Books on history.ID = $self.ID;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class CatalogService extends cds.ApplicationService { init(){
|
||||
})
|
||||
|
||||
// Add some discount for overstocked books
|
||||
this.after ('READ','Books', each => {
|
||||
this.after ('READ','ListOfBooks', each => {
|
||||
if (each.stock > 111) {
|
||||
each.title += ` -- 11% discount!`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user