Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 1.51 KB

File metadata and controls

81 lines (60 loc) · 1.51 KB

Domain Modeling

This tutorial shows how to create entities, attributes, enumerations, and associations.

Create an Enumeration

Enumerations define a fixed set of values:

mxcli -p App.mpr -c "
CREATE ENUMERATION MyFirstModule.Priority (
    Low 'Low',
    Medium 'Medium',
    High 'High',
    Critical 'Critical'
);
"

Create an Entity

Create a persistent entity with typed attributes:

mxcli -p App.mpr -c "
@Position(100, 100)
CREATE PERSISTENT ENTITY MyFirstModule.Customer (
    FirstName: String(100),
    LastName: String(100),
    Email: String(200),
    Phone: String(50),
    IsActive: Boolean DEFAULT true
);
"

Create an Association

Link entities together:

mxcli -p App.mpr -c "
CREATE ASSOCIATION MyFirstModule.Order_Customer
    FROM MyFirstModule.Order TO MyFirstModule.Customer
    TYPE Reference
    OWNER Default;
"

Modify an Existing Entity

Add attributes to an existing entity:

mxcli -p App.mpr -c "
ALTER ENTITY MyFirstModule.Customer
    ADD (Notes: String, CreatedDate: DateTime);
"

Run the Full Example

The 02-create-entity.mdl script creates a complete Task/Category domain model:

mxcli exec scripts/02-create-entity.mdl -p App.mpr

Verify Your Changes

After making changes, validate the project:

# Quick check with mx
~/.mxcli/mxbuild/*/modeler/mx check App.mpr

Next Steps