Skip to content

Tag: mongoose

How to handle for Cast Errors in MongoDB/mongoose

I am using mongoDB. I don’t like the default error message that is thrown by mongoose/mongoDB. I would like to check for the error type and if it is a cast error then I would like to send a different error message. Answer here is my function to do that. this function take an error and if it was a

TypeError: Order.find is not a function

I am building ecommerce website using MERN stack. And I am getting error while testing using Postman. backend/controllers/user.js backend/models/Order.js backend/models/User.js backend/routes/user.js Error:- TypeError: Order.find is not a function at exports.userPurchaseList (C:UsersRahulMernBootcampprojbacke…