-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: API
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
For some users and use cases, it is tedious/impractical to create options objects when calling driver methods that take them. We should provide overloads taking bsoncxx::document::view_or_value objects to make the driver more versatile and usable.
Consider a case where the user has a bson document that they have stored options in, either generated from some config file or read out of the database:
// aggregate options { "maxTimeMS" : 100, "explain" : true, "allowDiskUse" : false }
In order to run an aggregation query, these options must first be converted to an options::aggregate object:
bsoncxx::document::value agg_options_bson{some existing bson}; options::aggregate opts{}; opts.max_time_ms(agg_options_bson["maxTimeMS"].get_int64()); opts.explain(agg_options_bson["explain"].get_bool()); opts.allow_disk_use(agg_options_bson["allowDiskUse"].get_bool()); collection.aggregate(pipeline, opts);
If we provided an overload we could skip the options-building steps here and just pass in the original document:
bsoncxx::document::value agg_options_bson{some existing bson}; collection.aggregate(pipeline, agg_options_bson);
Edit:
Other methods that we should consider changing, in addition to collection::aggregate():
- collection::create_index()