Find document with array that contains a specific value

As favouriteFoods is a simple array of strings, you can just query that field directly:

PersonModel.find({ favouriteFoods: "sushi" }, ...);

model:
person = {
    name : String,
    favoriteFoods : Array
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to find document with any item include in array condition Find document with array that contains a specific id find document conatining a particular element in array write javascript function to find an array contains a specific element How to find document with array that contains a specific value? find an array item includes specific value javascript find a specific number in array javascript How to find document with array that contains a specific value check that element is in an array in mongooser mongoose find check if string is in an array mongoose query array mongoose find inside arr mongoose find any in array mongoose query from array field if array contains a value in mongoose find mongoose array includes query an array mongoose mongoose filter in array of strings robomongo search array in array how to query inside array in mongoose mongoose find array element search in an array mongoose find all doc with a value in array array contains in mongodb mongoose find where array contains mongoose any from array search find document from array javascript mongoose find array field mongoose check if array contains value if value is in array mongoose mongodb findall with string in array mongoose search array $in at least one mongoose checek if array includes mongoose query check if includes mongoose array element found in other document how to search for mongoose doc based on array element find element in list and search string mongoose mongoose search with array mongoose where array contains find records containes array of elements mongoose find records containes array of elements ongoose how to find inside an array in mongoose get documents where element is present in array mongoose get documents where element is present in array how to find in array mongoose find document by array content search array in mongoose mongodb check whether string is present in arrray mongoose is element in array search arrays mongoose how to check whether a array contauins the specific value mongoose query how to check specific data is present in array which is attribut of model mongoose mongoose find using array elements how to find from array in mongoose mongoose find if array contains array items mongoose array contains mongo db find if string is in array mongodb find in array of str mongoose find array contains mongoose query find in array Find document with array that contains a specific value
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source