Understand the $eq operator mongodb

Viewed 21

In most of my queries, i am not using the $eq operator when i should make an equality for a field.

I am guessing that if this operator exists, it's not for nothing... So i would like to know :

  • Why / when should i use $eq ?
  • Regarding performance, is it better or worse than letting the field empty ?

You can answer both questions based on this example :

result_without_eq = my_collection.find({"_id": "anyID"})

result_with_eq = my_collection.find({"_id": {"$eq": "anyID"}})

0 Answers
Related