[CXX-1618] C++ Syntactic Delights Created: 26/Jul/18  Updated: 20/Jul/20  Resolved: 20/Jul/20

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: Epic Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CXX-1861 CXX Usability improvements Backlog

 Description   
  • More convenient C++ BSON builder syntax
  • Maybe a fast field lookup operator[]
  • Maybe cursor::foreach
  • Maybe a nicer way to iterate over bson elements. Right now, to iterate over a nested document or array, it's necessary to call get_document()/get_array():

for (auto&& element : doc["subarray"].get_array().value) {}

It should be possible to return an array or document iterator immediately, depending on the type of the element.

for (auto&& element : doc["subarray"]) {}

Ideas courtesy of ryan.timmons:

  • Maybe a bson_doc["item"].to_json() rather than to_json(bson_doc["item"]). A static method bsoncxx::document.from_json() would complement this nicely.
  • Better document best practices for usage of views/values/value_or_views, since this seems to be a common point of confusion.
  • Maybe a better way to go from a bson type to a native type, e.g. bson_val.as<int>()


 Comments   
Comment by Alexander Golin (Inactive) [ 20/Jul/20 ]

Moved tickets into CXX-1861 (CXX Usability Improvements), Closing this as duplicate

Generated at Wed Feb 07 22:03:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.