Fetching data inside a templates' events code


I want to test a few things that regards some data i have stored stored in a collection called exams. This is my code

					 'click .reactive-table tr': function() {
           Session.set('selectedPersonId', this._id); 
           var cursor = Exam.findOne(Session.get("selectedPersonId"));
           if (!cursor.count()) return;
            //Uncaught TypeError: cursor.count is not a function

Everytime i run the code by clicking a row,i get the error

//Uncaught TypeError: cursor.count is not a function

Why am i getting this error?.


You can use .count() on a .find() query, but not on a .findOne() query.


Just to expand on @vigorwebsolutions answer: find returns a cursor, findOne returns an object (document).