Domain Model in the Mendix Metamodel
Introduction
The domain model represents the data that is stored in your app. Each module has a domain model, consisting of entities, which have attributes of a certain type and associations with other entities.
Attributes have a value which can either be a StoredValue, which is a value stored in the database, or a CalculatedValue, which is computed from a Microflow.
The entities can also relate to each other through generalizations. Finally, you can define access rules, validation rules, event handlers and indexes for entities.
Graphical Overview
| Studio Pro Guide | Model SDK API Docs |
|---|---|
| Domain Model | TypeScript module domainmodels |
| Entities | DomainModel |
| Attributes | Entity |
| Associations | Association |
| Attribute |
Attributes
Entities can have multiple attributes. Each attribute has a specific type.
Graphical Overview of Non-Numeric Attributes
Graphical Overview of Numeric Attributes
| Studio Pro Guide | Model SDK API docs |
|---|---|
| Attributes | Property attributes of entity |
| Attribute | |
| AttributeType |
Generalization Relationships
Entities can have a Generalization relationship with another entity. The entity is then called a Specialization. A specialization entity inherits all attributes, validation rules and access rules from its Generalization entity.
An Entity instance has a generalization property with which to define this relationship. It can either be set to a NoGeneralization instance if it is not a specialization of another entity, or it can be set to a Generalization instance. A Generalization instance has again a generalization property which must point to the entity that is the actual generalization.
Graphical Overview
| Studio Pro Guide | Model SDK API docs |
|---|---|
| Entities | Property generalization of Entity |
| GeneralizationBase | |
| Generalization | |
| NoGeneralization |
Access Rules
To secure access to the data in a Mendix app, you can define access rules for entities. An access rule is always defined for a certain module role, defines to which attribute or association members that role has access, and the retrieved data is constrained by an XPath constraint.
Graphical Overview
| Studio Pro Guide | Model SDK API docs |
|---|---|
| Access rules | Property accessRules of Entity |
| AccessRule | |
Property xpathConstraint of AccessRule |
|
| ModuleRole |
Validation Rules
For each attribute of an entity, it is possible to define a validation rule. The validation rule is applied to a single attribute, will show some error message, and it is a certain type of rule, for example, the attribute needs to be equal to a certain value, or has a maximum length, or needs to be unique.
Graphical Overview
| Studio Pro Guide | Model SDK API docs |
|---|---|
| Validation Rules | Property validationRules of Entity |
| ValidationRule | |
| RuleInfo |
Indexes
An entity can have multiple indexes. Each index consists of a set of indexed attributes.
Graphical Overview
| Studio Pro Guide | Model SDK API docs |
|---|---|
| Indexes | Property indexes of Entity |
| Index | |
| IndexedAttribute |