Check out example codes for "mongodb find documents where two fields are equal". It will help you in understanding the concepts better.

Code Example 1

db.myCollection.find( { $where: "this.a1.a != this.a2.a" } )

Learn ReactJs, React Native from akashmittal.com