Let's say I have this schema
{
jedi: [{
name:String
lightsaber_color:String
]}
}
I want to return all and only the names of them. I tried
Jedi.find({})
.select('jedi.name')
.exec(function (err, jedi) {
if (err) {
console.log("nothing found")
}
}
It returns me nothing, while this code returns me everything.
Jedi.find({})
.select('jedi')
.exec(function (err, jedi) {
if (err) {
console.log("nothing found")
}
}
I see that jedi is an array so I think that .select('jedi.name') may not work for this reason.
What is the right syntax to do so?