Mongocxx driver tutorial errors

I am pretty new to using mongocxx and I have built my driver successfully without errors on Ubuntu (using tarball), and I am currently giving it a run on the tutorial here

However, when I get to,

bsoncxx::document::element element = view["name"];
if(element.type() != bsoncxx::type::k_string) {
  // Error
std::string name = element.get_string().value.to_string();

I am getting an error of “error: ‘class bsoncxx::v_noabi::document::element’ has no member named ‘get_string’”

Is this a problem with my build or is there something missing in the tutorials? I tried looking up bsoncxx::v_noabi::document::element documentation, and there’s indeed not a get_string() member function.

the documentation that I used is here: MongoDB C++ Driver: src/bsoncxx/document/element.hpp Source File

Thank you for bringing this up @kelvin_kam! That is an issue with our documentation. We will update our documentation soon. Please use the get_utf8 method instead.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.