Find documents where a field is of type double or string

Problem Statement

Write mongodb query to find document where field named 'age' have type double or string

Collection Name: students

    _id: ObjectId('6626fb9e6548c947e716c9b7'),
    name: 'Joe Rogan',
    age: 35,
    country: 'USA'
    _id: ObjectId('6626fe516548c947e716c9b9'),
    name: 'Chris Williamson',
    age: 35.4,
    country: 'Austrelia'
    _id: ObjectId('6626fe666548c947e716c9ba'),
    name: 'Lex',
    age: '28',
    country: 'USA'

For more explaination of $type operator see : What is $type operator and how to use it?



When array is passed to $type operator then it will return document in which given field match any one of data type from the array.