Hilang definition Value


Values

| Definition | Dcoumentation | Property | ID | Expression | Hash | Prelude |

Element values consist of one or more values separated by commas. Each value can be a basic type, a value type or a reference to an entity or a segment. When an Entity is extended with a segment, a reference to the owner is added to the start of the key. Keys can also be a list of elements, but this is discouraged because the key can become very long. The notation uses open set “{“and close set “}” like a mathematical expression, where these are the values that are available from Hiperspace when you know key.

Plan Timesheet is an example of values defined with at type (like Typescript), and values. In this case Valid is a value derived prior to binding the Timesheet element.

entity Booking.Timesheet : Versioned
(
   Resource    : Plan.Resource,
   Task        : Plan.Tasks.Task,
   Date        : DateTime
)
{
   Time        : Decimal,
   "Estimated time to complete this task"
   Estimate    : Decimal,
   Comment     : String,
   Valid       = Resource = null ||             /* resource can not be null                                */
                 Task = null ||                 /* task can not be null                                    */
                 Date <= Task.Duration.Start || /* date before task start is invalid                       */
                 Date >= Task.Duration.End ||   /* date after task end is invalid                          */
                 Date <= Task.Actual.Close      /* Closing date for time booking in the Task Actual aspect */
                 ? false : true
}
[
   Cost        = Resource.TimeCost * Time,
];

Valid works like a database constraint when the SubSpace is open with the Horizon new Horizon<Booking.Timesheet>(p => p.Valid == true)


Value

Values either have a type or an expression that is evaluated when the element is bound to a SubSpace (if it does not have a value). The expression is used if the object does not have a value, in this example “Deleted = false” can be set prior to Bind() to tombstone the object: useful when CQRS uses different SubSpaces for load and read (for read, you’d want a Horizon filter to hide deleted elements, but would block Bind() if the element did not match the condition). “Valid = …” is an example where you’d want the Horizon filter to block write of invalid values).

Copyright © Cepheis 2024