I am learning about promises and updating documents in mongoose. I have a promise that is working when I include a "resolve" argument but not without that argument, and I can't figure out how to remove it for purposes of streamlining the code. I checked this question and this one about .save() but still don't understand if this is possible - I am still learning the ins and outs of promises. I got it to work with a Promise.all but not a single Promise. Here is the working request:
function updateQuantities(){
return new Promise((resolve)=>{
var conditions = {'titleByDate.instanceId' : {$ne: null}};
var update = {'titleByDate.currentQuantity': 0,'titleByDate.newTitle': 0};
resolve(titleRecords.update(conditions, update, options));
})
}
updateQuantities().then(/*a bunch of other promises*/)
And this one does not work, it gives an 'unexpected token var' error:
function updateQuantities(){
return new Promise(
var conditions = {'titleByDate.instanceId' : {$ne: null}};
var update = {'titleByDate.currentQuantity': 0,'titleByDate.newTitle': 0};
return titleRecords.update(conditions, update, options);
)
}
updateQuantities().then(/*a bunch of other promises*/)
Is there any way I can write the bottom one so that it works and I don't have to use resolve()? Thanks.