In MongoDB, you can use the $type element query operator to filter a collection of documents based on BSON type. It returns just those documents that have a particular BSON type in a specific field.
You provide the field and the BSON type, and $type will return all documents that match.