document.save()
calls your function and provides the values for err
and data
. If it is successful it sets data
to the record it inserted in the database, which a copy of the object you gave it with extra fields.
done
is a callback you provide when you call createAndSavePerson
. It is called in server.js
but for debugging purposes you can call it yourself with something like this:
createAndSavePerson(function(err, data){
if (err) console.error(err);
else console.log(data);
});