-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Bulk API
-
Completed
-
The mongocxx::bulk_write class is at present write-only; one can only append() to it.
Execution of an empty bulk_write is illegal and will result in an exception.
It would be convenient if this class were to expose a bool empty() const function, or, alternately, an explicit boolean conversion operator, by which to determine that it's valid or invalid for execution.
Commonly, when dealing with bulk writes, one is attempting to collate writes for performance, and execution of collated writes by a background thread is a reasonable implementation choice. In that our purported background thread presumably has no direct knowledge of the origin of the bulk_write operations it's being handed, addition of this support to bulk_write would simplify such implementations in that the thread could validate the bulk_write prior to calling execute().
Absent this support, one tends to build up a lot of scaffolding to avoid empty bulk_write operations in a generic context such as the one described.