DataAssociationMapping class describes the association between two models.
An association between two models is described in field attributes. For example
model Order may have an association with model Party (Person or Organization) through the field Order.customer:
{ "name": "Order",
"fields": [
...
{
"name": "customer",
"title": "Customer",
"description": "Party placing the order.",
"type": "Party"
}
...]
}
This association is equivalent with the following DataAssociationMapping instance:
"mapping": {
"cascade": "null",
"associationType": "association",
"select": [],
"childField": "customer",
"childModel": "Order",
"parentField": "id",
"parentModel": "Party"
}
The above association mapping was auto-generated from the field definition of Order.customer where the field type (Party)
actually defines the association between these models.
Another example of an association between two models is a many-to-many association. User model has a many-to-many association (for user groups) with Group model:
{ "name": "User",
"fields": [
...
{
"name": "groups",
"title": "User Groups",
"description": "A collection of groups where user belongs.",
"type": "Group",
"expandable": true,
"mapping": {
"associationAdapter": "GroupMembers",
"parentModel": "Group",
"parentField": "id",
"childModel": "User",
"childField": "id",
"associationType": "junction",
"cascade": "delete"
}
}
...]
}
This association may also be defined in Group model:
{ "name": "Group",
"fields": [
...
{
"name": "members",
"title": "Group Members",
"description": "Contains the collection of group members (users or groups).",
"type": "Account",
"many":true
}
...]
}