Reputation: 160
Db.test.find({field1: true, field2: true})
Db.test.find({$and:[{field1: true},{field2:true}]})
I fired a count on both these queries and the count was same Help appreciated
Upvotes: 1
Views: 26
Reputation: 784
Those two queries are effectively the same.
According to the MongoDB documentation:
MongoDB provides an implicit AND operation when specifying a comma separated list of expressions. Using an explicit AND with the $and operator is necessary when the same field or operator has to be specified in multiple expressions.
source: https://docs.mongodb.com/manual/reference/operator/query/and/
Upvotes: 3