How to save array of objects in mongoose
Of course, the above answer works, consider this as an alternative.
var defaultArray = ["A","B","C"];
var schemaDef = mongoose.Schema(
permission: { type: Array, default: defaultArray },
);
You need to create a mongoose model after you create your schema, and then you can save it. Try something like this:
var ProductSchema = new Schema({
name: String,
conditions: [{}],
colors: [{}]
});
var Product = mongoose.model('Product', productSchema);
var product = new Product({
name: req.body.name,
conditions: req.body.conditions,
colors: req.body.colors
});
product.save( function(error, document){ //callback stuff here } );