Skip to content

Commit

Permalink
Add a description of the code in each use case
Browse files Browse the repository at this point in the history
  • Loading branch information
Sv7enNowitzki committed Apr 8, 2024
1 parent 4ad663e commit 2620584
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ Use cases for Object ID annotation

#### Use Case 1: Annotate single field/multiple fields of associated table(s) as the Object ID

Modelling in `db/schema.cds`

```cds
entity Incidents : cuid, managed {
...
Expand All @@ -248,6 +250,11 @@ entity Incidents : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [customer.name, urgency.code, status.criticality] {
title @changelog;
}
Expand All @@ -258,6 +265,8 @@ annotate ProcessorService.Incidents with @changelog: [customer.name, urgency.cod

#### Use Case 2: Annotate single field/multiple fields of project customized types as the Object ID

Modelling in `db/schema.cds`

```cds
entity Incidents : cuid, managed {
...
Expand All @@ -273,6 +282,11 @@ entity Customers : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [customer.email, customer.phone] {
title @changelog;
}
Expand All @@ -283,6 +297,8 @@ annotate ProcessorService.Incidents with @changelog: [customer.email, customer.p

#### Use Case 3: Annotate chained associated entities from the current entity as the Object ID

Modelling in `db/schema.cds`

```cds
entity Incidents : cuid, managed {
...
Expand All @@ -296,6 +312,11 @@ entity Customers : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [customer.addresses.city, customer.addresses.postCode] {
title @changelog;
}
Expand All @@ -312,6 +333,8 @@ Use cases for tracing changes

#### Use Case 1: Trace the changes of child nodes from the current entity and display the meaningful data from child nodes (composition relation)

Modelling in `db/schema.cds`

```cds
entity Incidents : managed, cuid {
...
Expand All @@ -325,6 +348,11 @@ aspect Conversation: managed, cuid {
message : String;
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [title] {
conversation @changelog: [conversation.message];
}
Expand All @@ -335,6 +363,8 @@ annotate ProcessorService.Incidents with @changelog: [title] {

#### Use Case 2: Trace the changes of associated entities from the current entity and display the meaningful data from associated entities (association relation)

Modelling in `db/schema.cds`

```cds
entity Incidents : cuid, managed {
...
Expand All @@ -349,6 +379,11 @@ entity Customers : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [title] {
customer @changelog: [customer.email];
}
Expand All @@ -359,6 +394,8 @@ annotate ProcessorService.Incidents with @changelog: [title] {

#### Use Case 3: Trace the changes of fields defined by project customized types and display the meaningful data

Modelling in `db/schema.cds`

```cds
type StatusType : Association to Status;
Expand All @@ -369,6 +406,11 @@ entity Incidents : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [title] {
status @changelog: [status.code];
}
Expand All @@ -379,6 +421,8 @@ annotate ProcessorService.Incidents with @changelog: [title] {

#### Use Case 4: Trace the changes of chained associated entities from the current entity and display the meaningful data from associated entities (association relation)

Modelling in `db/schema.cds`

```cds
entity Incidents : cuid, managed {
...
Expand All @@ -393,6 +437,11 @@ entity Customers : cuid, managed {
...
}
```

Add the following `@changelog` annotations in `srv/change-tracking.cds`

```cds
annotate ProcessorService.Incidents with @changelog: [title] {
customer @changelog: [customer.addresses.city, customer.addresses.streetAddress];
}
Expand Down

0 comments on commit 2620584

Please sign in to comment.