Reputation: 10015
I'm writing a simple query that's using objects with propery Tags
and has to return a document if following is true:
:image
:
but is not an image:
So I want records of type { Tags : [":image", ":ianything", "somethingelse"] }
I write following:
db.myCollection.find({
Tags: {
$elemMatch: {
$eq: ":image"
},
$elemMatch: {
$ne: ":image",
$regex: /^:\w+$/
},
$elemMatch: {
$regex: /^\w+$/
},
$size: 3
}
}).limit(50)
But it doesn't work as expected and return items like { Tags : [":image", "something", "somethingelse"] }
Where am I mistaken?
Upvotes: 0
Views: 690