The duplicate question on StackOverflow has an answer provided (by another user), which solves for null and non-null entries. (Has been marked as accepted there.)

Mongo Playground with only null result
Mongo Playground with non-null result

1 Like