Reputation: 146
can someone help me?
I'm trying to update my Mongoose Schema and add to it an Array like this : I want to add to my ProductSchema the "attribute" ( I don't know how we call this, sorry ^^') description and in this description, you have multiple attributes lile brand, model, size, color, ...
I did something like this but (I don't think it worked) :
...
description: [
{ brand: String },
{ model: String },
{ size: String },
{ color: String },
{ year: Number },
{ State: String }
]
...
Thank's for your time !
UPDATE:
In fact, I don't need an array for the description, that was a stupid question ^^'
I can do something like this :
...
description: {
brand: String,
model: String,
size: String,
color: String,
year: Number,
State: String
}
...
Upvotes: 0
Views: 75
Reputation: 5931
Sure, you don't need an array if there is only one "decription" in your document schema.
However, if you need to store multiple descriptions, you can use :
...
description: [{
brand: String,
model: String,
size: String,
color: String,
year: Number,
State: String
}]
In your first attempt, you've made each property of your object an object itself.
Upvotes: 1