MongoDB findOne() Returning Weird Object - Can Someone Interpret It?

OP is originally dealing with a POST method not a GET method. Are you referring to the issue tracker project rather than the url shortener project?

EDIT, I understand what you are saying.

The original question was about what the findOne() method returned. This is a Mongoose method that is independent of the type of method used in Express, whether that’s a GET method or a POST method. Also, it’s independent of whether or not we’re dealing with the ‘Issue Tracker’ project or the ‘URL Shortener’ project. You could use the findOne() method (or other Mongoose query method) to find whether or not a document exists in the database, either in an express POST method or GET method. For example, say you wanted to register a new user using a POST method, you could first check the database to see if a user with a certain email address was already registered or not before creating a new user document.

1 Like

Basically, yes. I would suggest using async/await because it is simpler and it allows you to store the result of the database document query to a variable and use it later within your Express method (GET, POST or otherwise).

Keep up the good work. You’re almost finished with the certificate!

1 Like

I have the same problem
when I had gone through my code I found that I had not imported the connection file in my index.js file
so mongoose return the object of my query base on my model schema