title: mongoose generating a children field using parent field
body: <p>I am trying to create a family tree website using mongodb. upon creating a new family member, i only want to reference the parent (father) of the person and have mongoose automatically generate a children field in the person model. Here is the Person schema:</p>
  
  <pre><code>Person.add({
      fullName: { type: String, initial:true, required: true,label: , index:true,  },
      parent: {type: Types.Relationship, ref:'Person'},
  });
  </code></pre>
  
  <p>As you can see, upon creating a new person, I would want mongoose to automatically find all people in the Person model with the parent id matching the person I'm creating and generate an array of ids in the children field.</p>
  
  <p>I have done some researches and found that Mongoose Virtuals can provide something like that but i have not found any documentation regarding querying the model to add to the virtual field. Thanks in advance!</p>