Hey,
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.
parent1: {
...
partners: {
[{
_id: parent2._id,
type: relationshipBetweenParents
}]
},
children: {
[{
_id: child._id,
with: parent2._id,
type: relationshipWithChild
}]
}
}
and the same for parent2
. My problem is ‘knowing’ the _id
of parent2
before I created that person and storing it in person1
.
Any suggestions on how to solve this?