In MongoDB, you can use the $exists
element query operator to match documents that contain a specific field.
You can also use it to match documents that don’t contain a specific field.
You can also use it in conjunction with other operators such $nin
to match documents where a given field exists, but it doesn’t contain a specific value.