samedi 3 août 2019

Query a String Using Stream Builder

When attempting to query, a MongoDB Document containing a KVP:

"Cell_Lon": "-105.2"

I try to use a std::string Cell_Lon variable to perform findOne query using the bson streambuilder:

bsoncxx::stdx::optional<bsoncxx::document::value> optional_value_result =
    collection.find_one(document{} << "Location.Cell_Lon" << Cell_Lon << finalize);

When I hardcode the Cell_Lon string to: "-105.2" the query works. I've tried adding "\"" and '\"' to each side of the string and using std::quoted to no avail.

I'm thinking there must be something in the bsoncxx library for this but can't figure it out. Thanks for the help!

Aucun commentaire:

Enregistrer un commentaire