This commit is contained in:
Daniel
2021-04-08 19:17:48 +02:00
parent 33cd70065a
commit 9479aa4cad
4 changed files with 26 additions and 3 deletions

1
.env Normal file
View File

@@ -0,0 +1 @@
# cdsc

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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!`
}