WriteResult

27 views
Skip to first unread message

Andrew Gee

unread,
Jul 22, 2016, 11:01:58 AM7/22/16
to ReactiveMongo - http://reactivemongo.org
Hi all,

We've been using reactivemongo in our project and have a question surrounding `WriteResult`. It seems by calling insert or update you receive a failed Future if there are any errors. 

If there aren't any errors you get a sucessful Future. However, the successful Future returns the `WriteResult` case class which includes possible errors. I see these `WriteError` error attributes are used to decide whether to fail the Future or not in the library. 

But this seems to us that it is never possible to get a WriteResult with an error in as a user of this API? This seems quite misleading to us and we think the `insert` and `update` functions should only return data associated with the successful result if the Future is successful. In this particular case, I'd assume only a number of affected documents would be returned.

Are we missing something in this design? Our main problem is that it seems misleading. Should we open a PR for this?

Thanks,
Andrew

Cédric Chantepie

unread,
Jul 22, 2016, 11:25:12 AM7/22/16
to ReactiveMongo - http://reactivemongo.org
Right, there is no longer any way to get an erroneous WriteResult from the public API (which is not the case internally).

Such change is not open to PR, as it should be considered with the compatibility refactoring.

Andrew Gee

unread,
Jul 22, 2016, 11:33:58 AM7/22/16
to ReactiveMongo - http://reactivemongo.org
On Friday, 22 July 2016 16:25:12 UTC+1, Cédric Chantepie wrote:
Right, there is no longer any way to get an erroneous WriteResult from the public API (which is not the case internally).

Great, thanks for clarifying that for us.
 

Such change is not open to PR, as it should be considered with the compatibility refactoring.

Can we at least put a warning in the documentation for WriteResult as a PR then, so others don't make the same mistake we did? :)
Reply all
Reply to author
Forward
0 new messages