diff --git a/db/common.cds b/db/common.cds index 1462a3f..5c18a6a 100644 --- a/db/common.cds +++ b/db/common.cds @@ -1,20 +1,20 @@ namespace company.project.common; using { - sap, - cuid, - managed, - temporal, - Currency, - Language, - Country, - sap.common.CodeList as CodeList, + sap, + cuid, + managed, + temporal, + Currency, + Language, + Country, + sap.common.CodeList as CodeList, } from '@sap/cds/common'; /** - * Entities are structured types with named and typed elements, representing sets of (persisted) data that can be read and manipulated using usual CRUD operations. + * Entities are structured types with named and typed elements, representing sets of (persisted) data that can be read and manipulated using usual CRUD operations. * They usually contain one or more designated primary key elements. - * + * * source: https://cap.cloud.sap/docs/cds/cdl#entity-definitions-%E2%80%94-define-entity */ @@ -22,14 +22,14 @@ using { // Entities // ------------------------------------------------------------------------------------ -entity SampleCommonEntity: cuid, managed, temporal { - propertyString: String; +entity SampleCommonEntity : cuid, managed, temporal { + propertyString : String; } /** * CDS's aspects allow to flexibly extend definitions by new elements as well as overriding properties and annotations. * They're based on a mixin approach as known from Aspect-oriented Programming methods. - * + * * source: https://cap.cloud.sap/docs/cds/cdl#aspects */ @@ -38,19 +38,19 @@ entity SampleCommonEntity: cuid, managed, temporal { // ------------------------------------------------------------------------------------ aspect SampleAspect1 { - propertyString: String; - propertyInteger: Integer; + propertyString : String; + propertyInteger : Integer; } -aspect SampleAspect2: managed, temporal { - propertyString: String; - propertyInteger: Integer; +aspect SampleAspect2 : managed, temporal { + propertyString : String; + propertyInteger : Integer; } /** - * You can declare custom types to reuse later on, for example, for elements in entity definitions. + * You can declare custom types to reuse later on, for example, for elements in entity definitions. * Custom-defined types can be simple, that is derived from one of the predefined types, structure types or Associations. - * + * * source: https://cap.cloud.sap/docs/cds/cdl#type-definitions-%E2%80%94-define-type */ @@ -58,18 +58,19 @@ aspect SampleAspect2: managed, temporal { // Types // ------------------------------------------------------------------------------------ -type SampleStringType : String(255); - +type SampleStringType : String(255); type SampleAssociationType : Association to SampleCommonEntity; type SampleStructuredType { - decimalProperty : Decimal(10,3); - currencyProperty : Currency; + decimalProperty : Decimal(10, 3); + currencyProperty : Currency; } -type SampleArrayedType : array of { property: String; } +type SampleArrayedType : array of { + property : String; +} -type SampleCodeListType : Association to SampleCodeList; +type SampleCodeListType : Association to SampleCodeList; // ------------------------------------------------------------------------------------ // Code Lists @@ -77,5 +78,5 @@ type SampleCodeListType : Association to SampleCodeList; @cds.odata.valuelist entity SampleCodeList : CodeList { - key code : String(20); + key code : String(20); } diff --git a/db/schema.cds b/db/schema.cds index d69b20d..1f11392 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -1,69 +1,69 @@ namespace company.project.db; using { - sap, - cuid + sap, + cuid } from '@sap/cds/common'; using { - company.project.common.SampleAspect1, - company.project.common.SampleAspect2, - company.project.common.SampleCommonEntity, - company.project.common.SampleAssociationType, - company.project.common.SampleArrayedType, - company.project.common.SampleCodeListType, + company.project.common.SampleAspect1, + company.project.common.SampleAspect2, + company.project.common.SampleCommonEntity, + company.project.common.SampleAssociationType, + company.project.common.SampleArrayedType, + company.project.common.SampleCodeListType, } from '../db/common'; entity SampleEntity : cuid, SampleAspect1 { - //======================================================================// - // Built-in Types (https://cap.cloud.sap/docs/cds/types#built-in-types) // - //======================================================================// + //======================================================================// + // Built-in Types (https://cap.cloud.sap/docs/cds/types#built-in-types) // + //======================================================================// - sampleUUID : UUID; // an opaque string | example: 'be071623-8699-4106-...' | sql: NVARCHAR(36) + sampleUUID : UUID; // an opaque string | example: 'be071623-8699-4106-...' | sql: NVARCHAR(36) - sampleBoolean : Boolean; // a boolean | example: true or false | sql: BOOLEAN + sampleBoolean : Boolean; // a boolean | example: true or false | sql: BOOLEAN - sampleUInt8 : UInt8; // an unsigned integer number stored with 8 bit | example: 0 to 255 | sql: TINYINT + sampleUInt8 : UInt8; // an unsigned integer number stored with 8 bit | example: 0 to 255 | sql: TINYINT - sampleInt16 : Int16; // an integer number stored with 16 bit | example: -32768 to 32767 | sql: SMALLINT + sampleInt16 : Int16; // an integer number stored with 16 bit | example: -32768 to 32767 | sql: SMALLINT - sampleInt32 : Int32; // an integer number stored with 32 bit | example: -2,147,483,648 to 2,147,483,647 | sql: INTEGER + sampleInt32 : Int32; // an integer number stored with 32 bit | example: -2,147,483,648 to 2,147,483,647 | sql: INTEGER - sampleInteger : Integer; // same as previous + sampleInteger : Integer; // same as previous - sampleInt64 : Int64; // an integer number stored with 64 bit | example: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | sql: BIGINT + sampleInt64 : Int64; // an integer number stored with 64 bit | example: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | sql: BIGINT - sampleInteger64 : Integer64; // same as previous + sampleInteger64 : Integer64; // same as previous - sampleDecimal : Decimal(10, 2); // a decimal number, usage -> 'Decimal(precision, scale)' | example: 15.2 | sql: DECIMAL + sampleDecimal : Decimal(10, 2); // a decimal number, usage -> 'Decimal(precision, scale)' | example: 15.2 | sql: DECIMAL - sampleDouble : Double; // a double number | example: DOUBLE 2.2250738585072014E-308 to 1.79769313486231570e+308d | sql: DOUBLE + sampleDouble : Double; // a double number | example: DOUBLE 2.2250738585072014E-308 to 1.79769313486231570e+308d | sql: DOUBLE - sampleDate : Date; // a date | example: '2021-06-27' | sql: DATE + sampleDate : Date; // a date | example: '2021-06-27' | sql: DATE - sampleTime : Time; // a time | example: '07:59:59' | sql: TIME + sampleTime : Time; // a time | example: '07:59:59' | sql: TIME - sampleDateTime : DateTime; // a Timestamp with second precision | example: '2021-06-27T14:52:23Z' | sql: TIMESTAMP + sampleDateTime : DateTime; // a Timestamp with second precision | example: '2021-06-27T14:52:23Z' | sql: TIMESTAMP - sampleTimestamp : Timestamp; // a Timestamp with µs precision | example: '2021-06-27T14:52:23.123Z' | sql: TIMESTAMP + sampleTimestamp : Timestamp; // a Timestamp with µs precision | example: '2021-06-27T14:52:23.123Z' | sql: TIMESTAMP - sampleString : String; // a String, usage -> 'String(length)' or 'String' for default length of 5000 (HANA) or 255 (Others) | example: 'hello world' | sql: NVARCHAR + sampleString : String; // a String, usage -> 'String(length)' or 'String' for default length of 5000 (HANA) or 255 (Others) | example: 'hello world' | sql: NVARCHAR - sampleBinary : Binary; // a String used to store binary data, usage | example: '0001 1100 1011 0101...' | sql: VARBINARY + sampleBinary : Binary; // a String used to store binary data, usage | example: '0001 1100 1011 0101...' | sql: VARBINARY - sampleLargeBinary : LargeBinary; // a String used to store BLOBs | example: '0001 1100 1011 0101...' | sql: BLOB + sampleLargeBinary : LargeBinary; // a String used to store BLOBs | example: '0001 1100 1011 0101...' | sql: BLOB - sampleLargeString : LargeString; // a Large String | example: 'Lorem Ipsum...' | sql: NCLOB + sampleLargeString : LargeString; // a Large String | example: 'Lorem Ipsum...' | sql: NCLOB - //=====================================================// - // My own defined entities, aspects, types, code lists // - //=====================================================// + //=====================================================// + // My own defined entities, aspects, types, code lists // + //=====================================================// - sampleCommonEntity : Association to one SampleCommonEntity; - SampleAspect2 : Composition of one SampleAspect2; - sampleAssociationType : SampleAssociationType; - sampleArrayedType : SampleArrayedType; - sampleCodeList : SampleCodeListType; + sampleCommonEntity : Association to one SampleCommonEntity; + SampleAspect2 : Composition of one SampleAspect2; + sampleAssociationType : SampleAssociationType; + sampleArrayedType : SampleArrayedType; + sampleCodeList : SampleCodeListType; } diff --git a/srv/sample-service-auth.cds b/srv/sample-service-auth.cds index 62e4e4e..55e3cd9 100644 --- a/srv/sample-service-auth.cds +++ b/srv/sample-service-auth.cds @@ -2,12 +2,12 @@ using {company.project.service.SampleService} from './sample-service'; annotate SampleService with @(requires: 'authenticated-user'); -annotate SampleService.SampleView with - @restrict: [{grant: [ - 'READ', - 'CREATE', - 'UPDATE' - ]}]; +annotate SampleService.SampleView with +@restrict: [{grant: [ + 'READ', + 'CREATE', + 'UPDATE' +]}]; -annotate SampleService.SampleReadOnlyView with - @(restrict: [{grant: ['READ']}]); \ No newline at end of file +annotate SampleService.SampleReadOnlyView with +@(restrict: [{grant: ['READ']}]); diff --git a/srv/sample-service-capabilities.cds b/srv/sample-service-capabilities.cds index 5228615..d704caa 100644 --- a/srv/sample-service-capabilities.cds +++ b/srv/sample-service-capabilities.cds @@ -1,13 +1,13 @@ using {company.project.service.SampleService} from './sample-service'; annotate SampleService.SampleView with { - sampleBinary @readonly; - sampleLargeBinary @readonly; - sampleLargeString @readonly; + sampleBinary @readonly; + sampleLargeBinary @readonly; + sampleLargeString @readonly; }; -annotate SampleService.SampleView with @Capabilities : { - InsertRestrictions.Insertable : true, - UpdateRestrictions.Updatable : true, - DeleteRestrictions.Deletable : false -}; \ No newline at end of file +annotate SampleService.SampleView with @Capabilities: { + InsertRestrictions.Insertable: true, + UpdateRestrictions.Updatable : true, + DeleteRestrictions.Deletable : false +}; diff --git a/srv/sample-service.cds b/srv/sample-service.cds index 3076619..4c089b8 100644 --- a/srv/sample-service.cds +++ b/srv/sample-service.cds @@ -3,26 +3,35 @@ namespace company.project.service; using {company.project.db as db} from '../db/schema'; -@impl : './handlers/sample-service-handler' +@impl: './handlers/sample-service-handler' service SampleService @(path: 'sample') { - entity SampleView as projection on db.SampleEntity { - * - } excluding { - sampleUUID, + entity SampleView as + projection on db.SampleEntity { + * + } + excluding { + sampleUUID, } actions { - action sampleAction ( id: UUID, bool: Boolean ); + action sampleAction(id : UUID, bool : Boolean); } - @readonly - entity SampleReadOnlyView as projection on db.SampleEntity { - sampleUUID, - sampleUInt8, - sampleBoolean - } - where sampleBoolean = true - group by sampleUUID - order By sampleUInt8 + @readonly + entity SampleReadOnlyView as + projection on db.SampleEntity { + sampleUUID, + sampleUInt8, + sampleBoolean + } + where + sampleBoolean = true + group by + sampleUUID + order by + sampleUInt8 - event SampleEvent: { id: UUID; bool: Boolean }; -} \ No newline at end of file + event SampleEvent : { + id : UUID; + bool : Boolean + }; +}