title: Two level nested mongoose schema
body: <p>I want to be able to create the following structure in mongoose</p>
  
  <pre><code>{
      "clientId": 9,
      "uniqueNodeId": "REFRESH:NODE:123123123_9_231",
      "parent": null,
      "status": "ACTIVE",
      "templates": [
          {
              "name": "temp",
              "body": "temp",
              "url": "temp",
              "imageUrl": "temp",
              "title": "temp",
              "personaId": 123,
              "status": "ACTIVE",
              "uniqueTemplateId": "REFRESH:TEMPLATE:123123123_9_231"
          }
      ]
  }
  </code></pre>
  
  <p>templates is an array and of json objects.What is the right way to do this?
  I tried doing the below code.</p>
  
  <pre><code>var folderSchema = mongoose.Schema({
      "clientId": {type: Number, required: true},
      "uniqueNodeId": {type: String, required: true},
      "parent": {type: String, required: true},
      "status": {type: String, required: true},
      "templates": [{
          "name": {type: String, required: true},
          "body": {type: String, required: true},
          "url": {type: String, required: true},
          "imageUrl": {type: String, required: true},
          "title": {type: String, required: true},
          "personaId": {type: String, required: true},
          "status": {type: String, required: true},
          "uniqueTemplateId": {type: String, required: true}
      }]
  });
  </code></pre>
  
  <p>However i am getting the following error:</p>
  
  <pre><code>TypeError: Undefined type at `paths.clientId`
    Did you try nesting Schemas? You can only nest using refs or arrays.
  </code></pre>
  
  <p>What does this mean and how to correct it?</p>