Why are Mongoose documents not JavaScript objects by default?

When you return Mongoose documents from the MongoDB database, you cannot just edit the returned document. You need to either convert it to a regular JavaScript object using a function .toObject()that doesn't work for me yet - or JSON.parse(JSON.stringify(doc))it,

My question is: why is this so? Why don't they just return as simple, simple, and easy to use default JavaScript objects?

+4
source share
1 answer

Mongoose , . document.save(...) , .

, , lean.

+5

All Articles