What is the best way to return all documents in a collection if I want document.a == document.b?
I\'ve tried
db.collection.aggregate([ { $match: { $
If I understood your question right you want those documents that have same values in field1 and field2.
For this try
db.coll.find({$where: function() { return this.field1 == this.field2 } } );
or more compact
db.coll.find({ $where : "this.field1 == this.field2" } );