English is not my first language, but I'm trying hard.
The problem is that I'm using a project using Mongoose, but I can't find a description of the parameter of the callback function in document.save().
The link gives me an accurate answer to my question, and the link's the genious who answered explains that there are three things in the callback parameter, but I can't find such an explanation anywhere in the official document, not just an option parameter, Callback parameter
But it's explained as if it's in the official document.
Am I a fool? I want to erase this pathetic question quickly. Help me, Bill Gates.
CodePudding user response:
The guide on how to execute queries mentions the following:
All callbacks in Mongoose use the pattern:
callback(error, result)
. If an error occurs executing the query, theerror
parameter will contain an error document, andresult
will be null. If the query is successful, theerror
parameter will be null, and the result will be populated with theresults
of the query.
Since the documentation for Document.prototype.save()
says nothing but:
[fn] «Function»
optional callback
So you know this function is no exception to the rule. As such, doc.save((err, doc) => { })
is the signature of the callback.