Mongodb java development using two fields equal query conditions should be how to write?

  mongodb, question

This is a condition like where field A= field B in sql. I checked some posts on the Internet that said there would be an error when using the method of $where for i query. It is similar to: New Document (“$ Where”, New Document (“Field A”, “Field B”)). Please ask me how to write it.

Mongo does not support queries in which two fields are compared with each other. You can only read and compare these two fields through the program. This effect cannot be achieved in query conditions.