I've hopefully a quick question for someone with a bit more knowledge than I.
If I have code in a Node api implementation which basically creates an entity and saves it directly to MongoDB using Mongoose, do I need to wrap all that in an promise library to get it as asynchronous as possible? Or will the implementation of the Mongoose/MongoDB Node libraries already do their work in an async fashion, so that my only overhead on the message pump is the object creation.
The code below is what we have in the API, it creates the promise below and executes it, I'm just wondering if the overhead of the promise is actually worth it if the Mongoose/MongoDB libraries are async anyway.
Hope all that makes sense.
function action(promise) {
var date = new Date(),
taskWorkQueue = new TaskWorkQueueModel({
"TaskId": taskid,
"metadata": metadata,
"State": 0,
"TaskType": taskType,
"ApplicationName" : token.ApplicationName ,
"dateEntered": date});
taskWorkQueue.save(function (err) {
if (err)
{
promise.reject(err);
}
else
{
promise.resolve(taskWorkQueue);
}
});