Handling Cascade Persistence¶
Create relation to existing entity¶
It is super easy to create relation to already existing entity. To do so you just need to pass uid
of the related object as a value of property. It works in exactly same way for One-To-One and Many-To-One relations for whom target entity contains information about one related entity. As on example below - we want to assign User
to Department
assuming that User
can belongs to only one Department
.
{
"department": 12
}
In similar way it works also for One-To-Many and Many-To-Many relations for whom target entity contains a collection of related entities. In such case to create relation it is needed to pass array of identifiers. In example below we create/update news and assign it to categories with specified identifiers.
{
"categories": [
10,
12,
13
]
}