问题
This is actually a continuation of my previous question and I'm reasking as I've realised I didn't quite ask the question problem and now I have a different error response.
This is in db.js, a separate file while I have the handlers.
Context: I return func
like this so that in my index.js, I can continue to perform mongodb sort
operation to find users with the smallest timestamp!
In my server console, I get this response.TypeError: db.findWConditionandler is not a function
I'm not sure what I'm doing wrong here. Pls advice! Thanks in advance!
回答1:
The problem is because .sort
expects a cursor and .findOne()
doesn't not give a cursor. Instead, one should use .find()
来源:https://stackoverflow.com/questions/61291191/typeerror-db-findwconditionandler-is-not-a-function-mongodb