Wrong signature calling mongodb update?
I had a completely other problem, however, I encounterned a possible fault in the mongodb store L389:
this.events.update({'_id' : id}, updateCommand, callback);
The corresponding function in the mongodb driver L1084 expects another signature:
Collection.prototype.update = function(selector, document, options, callback) {
No clue, why everything is still working... the function from mongodb does not handle this correctly, but returns a Promise instead of calling the callback.
Meanwhile, I found why everything is working. This is from the mongodb driver:
Collection.prototype.update = function(selector, document, options, callback) {
var self = this;
// [...]
// Execute using callback
if(typeof callback == 'function') return updateDocuments(self, selector, document, options, callback);
// Return a Promise
return new this.s.promiseLibrary(function(resolve, reject) {
updateDocuments(self, selector, document, options, function(err, r) {
if(err) return reject(err);
resolve(r);
});
});
}
The callback is not called in the first place, because we're calling it incorrectly. So, it proceeds and creates the promise. updateDocuments however, interprets options, which is our callback function, as the callback we'd expect to resolve the promise. updateDocument calls our callback from within the promise, but not the handler that ought to resolve the promise.
Eventually, we end with an unresolved promise...