How can I match a field in MongoDB with value from another field of the same collection.
For example from the collection test: (not exactly the same collection but it serves the need)
test:
{
"a" : "one",
"b" : "two",
"c" : "three"
"d" : "one"
}
I need to fetch document where value of 'a' matches the value of 'd'. I tried:
db.test.aggregate([
{$match:{a:'$d'}}
])
but no hope!!!
$expr(and aggregation operators) to match two fields within the document.findmethod (instead of an aggregation match) when used withexpr.