title: How to push nested arrays into mongo db in node js
body: <p>I am trying to <strong>POST</strong> Product data to mongo db using mongoose. <br/>
  <strong>Product Model</strong> <br/></p>
  
  <pre><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  
  var productsSchema = new Schema({
    //  productId: {type: _id, required: true, autoIndex: true},
      merchantId: {type: String, required: true},
      productName: {type: String, required: true},
      productDescription: {type: String, required: true},
      uploadDate: {type: Date, default: Date.now},
      productAttributes: [
          {
              size: {type: Number, required: true},
              colors: [
                  {
                      color: {type: String, required: true},
                      qty: {type: Number, required: true},
                      price: {type: Number, required: true},
                      images: [{
                          image1: {type: String, required: true},
                          image2: {type: String, required: false},
                          image3: {type: String, required: false}
                      }]
                  }
  
              ]
          }
      ],
      otherAttributes: {
          length: {type: Number, required: false},
          fabricType: {type: Number, required: false},
          sleeves: {type: String, required: false}
  
      }
  });
  </code></pre>
  
  <p><br/>
  <strong>CreateProductMethod</strong> <br/></p>
  
  <pre><code>module.exports.createProduct = function (product, callback) {
      var newProduct = new Products();
      newProduct.merchantId = product.merchantId;
      newProduct.productName = product.productName;
      newProduct.productDescription = product.productDescription;
      newProduct.productAttributes.size = product.productAttributes.size;
      newProduct.productDescription.colors.color=product.productAttributes.colors.color;
      newProduct.productDescription.colors.qty=product.productAttributes.colors.qty;
      newProduct.productDescription.colors.price=product.productAttributes.colors.price;
      newProduct.productDescription.colors.images.image1=product.productAttributes.colors.image1;
  
      Products.create(newProduct, callback);
  }; &lt;br/&gt;
  </code></pre>
  
  <p><strong>While **POSTING</strong> data to server I am getting this exception <strong>Cannot read Property 'color' of undefined at Function.module.exports.createProduct</strong><br/>
  Why I am getting this error? <br/><br/>
  Please Help.</p>