Tell us what’s happening:
I can’t understand the instructions. They do not make any sense to me since I have zero exposure to Node.js and MongoDB. I looked at the solution and can’t understand why it should be written in that way (why console.error(err) and done(null, data)? what even is err and data???).
Is there any learning resource for someone with zero background on Node.js and MongoDB? This set of challenges seem to be designed for experienced people.
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Challenge: MongoDB and Mongoose - Create and Save a Record of a Model
Have you already completed the earlier courses under the Back End Development and API section? The MongoDB and Mongoose course is the third in this section. The first two (Managing Packages with npm and Basic Node and Express) should hopefully give you a foundation to work from.
If are still struggling after these courses, I might suggest checking out the MongoDB Documentation, or checking out this FCC video on the subject.
As for your question, the previous lesson (Create a Model) briefly touches on this:
The done() function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating, or deleting. It’s following the Node convention, and should be called as done(null, data) on success, or done(err) on error.
Not everything is explained here, which is why I suggest taking a look at the documentation or tutorial if you still have unanswered questions.