Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues #13, #14 and #15 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/alfred/meta/model/model.js
Expand Up @@ -216,13 +216,12 @@ Model.prototype.find = function(query) {
});

stream.on('record', function(key, record) {
value.id = key;
var doc = self.instantiate(record.value);
doc.id = record.key;
stream.emit('document', doc);
});
return stream;

callback(stream);
});
});
return finder;
Expand Down
14 changes: 11 additions & 3 deletions lib/alfred/util/promises.js
@@ -1,3 +1,5 @@
var async = require('async');

var Promises = function() {
this.pendingCount = 0;
this.doneCallbacks = [];
Expand All @@ -13,10 +15,16 @@ Promises.prototype.add = function(promise) {
promise(function() {
self.pendingCount --;
if (self.pendingCount === 0) {
while (self.doneCallbacks.length > 0) {
cb = self.doneCallbacks.splice(0, 1)[0];

async.forEachSeries(self.doneCallbacks, function(callback, cb) {
self.doneCallbacks.splice(0, 1);
callback();
cb();
}
}, function(err) {
if(err) {
throw new Error();
}
});
}
});
};
Expand Down