How to save JSON array in to mongodb collection How to save JSON array in to mongodb collection mongoose mongoose

How to save JSON array in to mongodb collection


It appears you declared features to be a String in your schema instead of an Array of subdocuments. Mongoose is therefore casting the array from req.body to a string before it is saved. The following tweak to your schema should get you on the right track:

var properties = new Schema({  Category_Id : { type: String},  Sub_category_Id : { type: String},  features : [{    specification_field_type": String,    specification_name: String    // any other paths for features  }]      });