Because Mongo is document oriented and thus lacks a rigid schema, documents (for better or for worse) can have varying structures within a collection. In practice, you probably don’t see vastly differing documents within a collection; however, from time to time, various document fields might differ (as in, they might not be present). Take for example, the classic example of a business card: some cards (i.e. documents) might list a fax number while others might omit it. As another example, as an application and its corresponding data evolves, new fields might be added (or removed).

The $exists query selector facilitates finding documents that have (or do not have) specific fields. On more than one occasion, I’ve employed this query selector to find documents in need of a surgical update. For example, in a collection dubbed words with word documents that each contain an embedded definitions document collection, I can find those particular definitions that do not have a part_of_speech element like so: