lets say i have a
Persons collection and a
child which is stored in the collection. I want to create two parents as documents and store their relationships. There are two kinds of relationships.
- Relationship between parents (married, divorced, …) and 2. the relationship to their child (adopted, biological). So I have to create both parents and store the other parents _id in the other parent.
and the same for
parent2. My problem is ‘knowing’ the
parent2 before I created that person and storing it in
Any suggestions on how to solve this?
(Post must be at least 20 characters)
I have similar functionality in the app I’m building and have relationships nested within the person document. In my app the children are the primary record that is added first so I have their id. Then throughout my processes as parents are added, I have a server method that creates the parental reciprocal relationships to the child.
For the parent->parent relationships, you can ask the marital status on each parent or after parent2 is added and then use a meteor method after parent2 is created to create the reciprocal relationships.
My idea was to use the callback function of the inserts and updates to do the next step. Is that what you are doing?
Exactly, I’m passing the ID created or updated to a method to create reciprocal relationships.