A
A
Alexander Knyazev2017-05-19 10:41:12
MongoDB
Alexander Knyazev, 2017-05-19 10:41:12

What is the _doc property on the object received in the findOne callback in Mongoose?

What's the difference between the document object itself and the object obtained from that object's _doc property? In the logs, it displays the same thing, except that the order of the properties in the object changes. However, in the code I'm parsing, it is the _doc variant that is used to create the json web token.

User.findOne({username: request.body.username}, (error, document) => {
console.log(document._doc)
console.log(document);
token = jwt.sign(document._doc, config.secret);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question