wclr / mongoose-fill

Virtual async fileds for mongoose.js
61 stars 8 forks source link

Exec works only with Promise #13

Closed Aeonrush closed 8 years ago

Aeonrush commented 8 years ago

Hi When I tried to write this:

Art.find().fill('likes').exec(function (err, data) {
  res.send(data);
});

I didn't got response. But with this:

Art.find().fill('likesCount').exec().then(function (data) {
  res.send(data);
});

all works fine. And, can you explain how to catch errors with this? Will this work?

Art.find().fill('likesCount').exec().then(cbOk,  cbError);

Thanks

wclr commented 8 years ago

Hi, I'm not sure why this:

Art.find().fill('likes').exec(function (err, data) {
  res.send(data);
});

doesn't work, mongoose-fill seems not to mess with that mechanics.

And, can you explain how to catch errors with this? Will this work?

Yes will work, this is usual way to deal with errors when using promises.

wclr commented 8 years ago

Ah yes you probably right, I will look into it.

wclr commented 8 years ago

Fixed in 1.6, thanks for reporting.