Articles → MONGODB → $Expr Operator In Mongodb$Expr Operator In MongodbIn this article, we will discuss the $expr operator in MongoDB.Purpose The $expr operator is used to compare fields in the same document.Example Consider the following collection: -The requirement is to find the documents where the spent is more than the budget. So, the query would be: -db.mycollection.find({ $expr: { $gt: ["$spent", "$budget"] } })Output Posted By - Karan Gupta Posted On - Monday, April 8, 2024 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
db.mycollection.find({ $expr: { $gt: ["$spent", "$budget"] } })
Query/Feedback