If I query for all the documents in a collection the normal way, I have no issues: https://gist.github.com/2562954. The output of this is
found docs []
However, if I introduce Step (https://github.com/creationix/step), then the output is not an array of documents: https://gist.github.com/2562852. The output of this is:
found docs { options: { populate: {} },
safe: undefined,
_conditions: {},
op: 'find',
model: [Function: Model] }
what the heck is going on here? I'd really like to use a control-flow library with mongoose but this is driving me nuts!
Try this. I have a similar Step function working.
Note: I don't know if this is what's causing the problem, but when you do this in coffeescript, it adds "return" before models.Foobar.find({}).run(this);
step(
function getFoobar() {
models.Foobar.find({}).run(this);
}, function (err, docs) {
console.log('found docs', docs);
console.log('disconnecting');
return mongoose.disconnect(this);
}, function (err) {
if (err) {
throw err;
}
return console.log('disconnected');
});