I am new to Doctrine, mongo, and the ODM setting, and while playing with this setting in ZF1, I am trying to replicate a simple link to a restricted link. This is the situation and I would like to advise how to achieve this.
This is a simple mapping of the user role and>, so in a SQL situation, I would have the following tables:
Users
- id
- name
- role_id
Roles
- id
- name
Then the role_id user will be set to a foreign key constraint for matching the role identifier. And when the role is deleted, the foreign key restriction that stops the operation will be violated.
How could I achieve the same goal in Doctrines MongoDB ODM?
So far, I have played with various types of annotations on a User object, including @ReferenceOne @ReferenceMany with various cascade options ...
Now I can only implement the events @PreUpdate, @PreRemove of the life cycle in the "role" entity, and then check that none of the users use this role, if they are later updated, change the link to match or delete the exception.
Am I right here or lost?
Thank,
Si
source
share