Find documents where _id of document is of type ObjectId

Problem Statement

Write mongodb query to find documents where _id of document is of type ObjectId.

Collection Name: students

[
  {
    _id: 1,
    name: 'Joe Rogan',
    age: 35,
    country: 'USA'
  },
  {
    _id: ObjectId('6626fe516548c947e716c9b9'),
    name: 'Chris Williamson',
    age: 35.4,
    country: 'Austrelia'
  },
  {
    _id: 3,
    name: 'Lex',
    age: 28,
    country: 'USA'
  }
] 

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

Solution

 db.students.find({"_id":{$type:"objectId"}})