Count documents

I am looking to use the count in mongo db to count the number of students qualified please see image above“qualifications”); isnt working

Hello @Marie_Dillane, welcome to the community.

The method you are trying“qualifications”) doesn’t work. This is because the method you are using is the cursor.count, and it doesn’t take a parameter.

  • counts all documents in the collection.
  • counts all documents in the collection which match the query condition.
  • db.collection.countDocuments(query) counts documents that match the query in a collection.

You can use the $exists to find documents that have the field qualifications using one of these queries: { qualifications: { $exists: true } } ).count() { qualifications: { $exists: true } } )