I'd like to find documents from a collection that has for example a category 'cat'
i.e.
[{id: 0, name: 'cheetah', category: ['cat', 'has_claws']},
{id: 1, name: 'lion', category: ['cat', 'has_claws', 'alpha']},
{id: 2, name: 'fox', category: ['dog']},
{id: 3, name: 'eagle' category: ['bird', 'has_claws']}
]
What does the query should look like? For example, I wanted to query allo animals that is in the category has_claws, I also wanted to make sure, there wouldn't be any duplicates, when I query using an array instead..
I.e. I want to query animals that is in cats and in has_claws
I thought using $in will suffice
$query = array('category' => array('$in' => array('cat', 'has_claws')));
$animals = $animalModel->find($query);
is there a native function to do this,