I’m trying to make a $and
clause within a $match
clause. This $and
clause should have a full complete comparison against the string I’m providing. I’d like to make sure that the comparisong with attributes.value
should be exact the string I’m passing. With the following expression:
db.getCollection('cards').aggregate([{
"$match" : {
"$and" : [
{ "attributes.key" : "setCode", "attributes.value" : "qc" },
{ "attributes.key" : "code", "attributes.value" : "potions" }
]
}
}
I can get results that match with the code like potion
, potions
, cauldron potion
. I’m also getting results where other attributes with different keys, have the word potions
within.
So my $match
clause is not respecting the attributes.key
with values setCode
and code
, because it’s comparing with other attributes.
How can I make sure that the above $match
condition matches only the given keys and given values?
Thank you all!