tingodb icon indicating copy to clipboard operation
tingodb copied to clipboard

Is this compatible with */yield/co?

Open MRokas opened this issue 8 years ago • 1 comments

This seems to be fine:

users.findOne(function (err, result) {
  if (err) console.error(err);
  console.log(result)
});

However this doesn't seem to work:

co(function *() {
  var list = yield users.findOne().toArray();
  console.log(list);
}).catch((err)=>{
  console.log(err);
});

MRokas avatar Aug 04 '16 19:08 MRokas

I don't expect your example to work, because collection.findOne() doesn't return a promise.

sam-artuso avatar Feb 04 '17 21:02 sam-artuso