title: mongoose different ways to reference subdocuments?
body: <p>This syntax is straight from the mongoose documentation on subtypes. However, I've also seen this alternate reference to subdocs. What is the difference?</p>
  
  <p><a href="https://mongoosejs.com/docs/subdocs.html" rel="noreferrer">https://mongoosejs.com/docs/subdocs.html</a></p>
  
  <pre><code>var childSchema = new Schema({ name: 'string' });
  
  var parentSchema = new Schema({
    // Array of subdocuments
    children: [childSchema],
    // Single nested subdocuments. Caveat: single nested subdocs only work
    // in mongoose &gt;= 4.2.0
    child: childSchema
  });
  </code></pre>
  
  <p>An alternate type of reference to subdocs</p>
  
  <pre><code>var childSchema = new Schema({ name: 'string' });
  
  mongoose.model('children', childSchema);
  
  var parentSchema = new Schema({
    children: {
      type: Schema.Types.ObjectId,
      ref: 'children'
    },
  });
  </code></pre>