The Schema looks like this
var DepartmentSchema = new Schema({
name:String,
major:[{
name:String
}]
});
Then I want to match all the items with a certain value in the array, such as {name: “name”} in the major array.
So this is it.
DepartMentModel.findOne({major:{name:"name"}});
However, there was no match.
Is my matching criteria not correct
DepartMentModel.find({major.name: “name”});