sorry, really simple question. I have a mongo collection and it's documents have a property that is an array of ObjectId's
projects
{
admins:[ObjectId('1'),ObjectId('2'),ObjectId('3')]
}
Using compass filters, How do i get all documents that have a certain ID in the admin array?
If you want to filter by one id.
{ admins: ObjectId('2') }
Or if you want to filter by using multiple admin's ids using $in
:
{ admins: { $in: [ ObjectId('1'), ObjectId('2') ] } }