Namespaces

This commit is contained in:
Wolfgang Koch
2021-05-06 17:12:45 +02:00
parent be657cbbcb
commit 66d792d76d
6 changed files with 29 additions and 29 deletions

View File

@@ -1,3 +1,3 @@
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Customer_ID;priority
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_Customer_ID;Z_priority
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;8e2f2640-6866-4dcf-8f4d-3027aa831cad;high
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;74e718c9-ff99-47f1-8ca3-950c850777d4;low
1 ID createdAt createdBy buyer OrderNo currency_code Customer_ID Z_Customer_ID priority Z_priority
2 7e2f2640-6866-4dcf-8f4d-3027aa831cad 2019-01-31 john.doe@test.com john.doe@test.com 1 EUR 8e2f2640-6866-4dcf-8f4d-3027aa831cad 8e2f2640-6866-4dcf-8f4d-3027aa831cad high high
3 64e718c9-ff99-47f1-8ca3-950c850777d4 2019-01-30 jane.doe@test.com jane.doe@test.com 2 EUR 74e718c9-ff99-47f1-8ca3-950c850777d4 74e718c9-ff99-47f1-8ca3-950c850777d4 low low

View File

@@ -7,17 +7,17 @@ using {
cuid, managed, Country
} from '@sap/cds/common';
namespace sap.bookshop.extension;
namespace Z_bookshop.extension;
// extend existing entity
extend orders.Orders with {
Customer : Association to one Customers;
Remarks : Composition of many Remarks on Remarks.parent = $self;
priority : String @assert.range enum {high; medium; low} default 'medium';
Z_Customer : Association to one Z_Customers;
Z_Remarks : Composition of many Z_Remarks on Z_Remarks.parent = $self;
Z_priority : String @assert.range enum {high; medium; low} default 'medium';
}
// new entity - as association target
entity Customers : cuid, managed {
entity Z_Customers : cuid, managed {
email : String;
firstName : String;
lastName : String;
@@ -25,18 +25,18 @@ entity Customers : cuid, managed {
dateOfBirth : Date;
status : String @assert.range enum {platinum; gold; silver; bronze} default 'bronze';
creditScore : Decimal @assert.range: [ 1.0, 100.0 ] default 50.0;
PostalAddresses : Composition of many CustomerPostalAddresses on PostalAddresses.Customer = $self;
PostalAddresses : Composition of many Z_CustomerPostalAddresses on PostalAddresses.Customer = $self;
}
// new unique constraint (secondary index)
annotate Customers with @assert.unique: { email: [ email ] }
annotate Z_Customers with @assert.unique: { email: [ email ] }
{
email @mandatory; // mandatory check
}
// new entity - as composition target
entity CustomerPostalAddresses : cuid, managed {
Customer : Association to one Customers;
entity Z_CustomerPostalAddresses : cuid, managed {
Customer : Association to one Z_Customers;
description : String;
street : String;
town : String;
@@ -44,7 +44,7 @@ entity CustomerPostalAddresses : cuid, managed {
};
// new entity - as composition target
entity Remarks : cuid, managed
entity Z_Remarks : cuid, managed
{
parent : Association to one orders.Orders;
number : Integer;