Problem
You have this schema:
person = {
name : String,
favoriteFoods : Array
}
where the favoriteFoods
array is populated with strings. How can I find all persons that have sushi
as their favorite food using MongoDB?
Consider:
PersonModel.find({ favouriteFoods: "sushi" }, ...);
PersonModel.find({ favouriteFoods: { "$in" : ["sushi"]} }, ...);