По какой-то причине функции, вызываемые в моем объекте курсора, не найдены. Вот мой код:ТипError: undefined не является функцией - Node.js & MongoDB
var db = req.db;
var goalscollection = db.get('goalscollection');
var collection = db.get('hoursburnedcollection');
var cursor = collection.find({goal: selectedgoal}, console.log);
// the line above prints the correct cursor object
var doc = cursor.hasNext() ? cursor.next() : null; //line 51
// the line above gives an error
Вот ошибка:
TypeError: undefined is not a function
at /Users/chrispark/Projects/LifeTool/node/routes/index.js:51:27
at Layer.handle [as handle_request] (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/layer.js:95:5)
at /Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/index.js:330:12)
at next (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/index.js:271:10)
at Function.handle (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/index.js:176:3)
at router (/Users/chrispark/Projects/LifeTool/node/node_modules/express/lib/router/index.js:46:12)
Есть ли что-то я не хватает? Заранее спасибо.
убедитесь, что ваш 'collection' не неопределенная –
моя коллекция не определена. курсор правильный (т. е. содержит нужные документы) –