Questions tagged [mongo-cxx-driver]

Officially supported C++ driver for MongoDB

The MongoDB C++ Driver is an officially supported driver for MongoDB. It is written in C++11. It wraps the MongoDB C Driver.

More information:

259 questions
7
votes
2 answers

New C++ Mongo driver: how to see type and how to get string value

I've got two questions that I cannot find an answer for in the tutorial. I get a document and then an element from the doc like this: bsoncxx::document::element e = doc["id"]; if (!e || e.type() != bsoncxx::type::k_int32) return…
Xauxatz
  • 143
  • 2
  • 9
6
votes
1 answer

mongoDB c++11 Driver get ID of inserted Document

I'm working with new c++11 mongoDB driver ( NOT the Legacy Driver ). I'm trying to get the 'id' of a document in mongoDB after I inserted a new document. This ID is in the returned value 'retVal3'. struct…
Cutton Eye
  • 3,207
  • 3
  • 20
  • 39
5
votes
3 answers

Error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory

I installed the mongocxx driver, as shown by http://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/ and when I test driver everything looks fine, but if change a little code I get error while loading shared libraries:…
Adam
  • 61
  • 1
  • 3
5
votes
3 answers

Mongodb c++ regex query

How to query MongoDB database using regex in c++. mongo-cxx-driver-r3.1.1 hear is include #include #include #include #include #include #include…
Sam Jamali
  • 77
  • 4
5
votes
1 answer

MongoDB C++, How to add ISODate value when inserting

This is about the new MongoDB C++ Driver (not the legacy one). I can insert a document this way: value Value = document{} <<"Key" <<"Value" <
Dee
  • 7,455
  • 6
  • 36
  • 70
5
votes
1 answer

when to use finalize in mongodb cxx r3.0.2 driver

I am confused, in code snippets of online doc, it shows the usage of finalize when calling update_many method, like so: mongocxx::stdx::optional result = collection.update_many( document{} << "i" << open_document << …
Dean Chen
  • 3,800
  • 8
  • 45
  • 70
5
votes
1 answer

How to save mongodb array into vector using c++ driver?

For example, if I do this in shell > db.numbers.save( { name: "fibonacci", arr: [0, 1, 1, 2, 3, 5, 8, 13, 21] } ) Then i want to get arr in my c++ program. After i got BSONObj i can get name with std::string name = p.getStringField("name"); where…
Stals
  • 1,543
  • 4
  • 27
  • 52
4
votes
0 answers

Mongocxx driver fails to connect using X.509 certificate authentication

I am tring to implement X.509 certificate authentication for Mongo using C++ driver. The driver is 3.4.0(custom build with enabled OpenSSL), C driver is 1.13.0, running on Debian 9, the server is Mongo 3.2 Code to connect: …
4
votes
1 answer

Converting a BSON document containing an array to JSON, removes the array from the converted JSON (C++)

I have a document that looks like this: { "_id" : ObjectId("5bd37e0128f41363c0006ac2"), "source" : "Forge", "data" : [ { "symbol" : "EURUSD", "bid" : 1.14021, "ask" : 1.14024, …
Zeiko
  • 41
  • 4
4
votes
1 answer

Building mongo-cxx-driver using CMake ExternalProject_Add

I am trying to build mongo-cxx-driver in a CMake based project. This project is supposed to build on Windows, macOS and in an ubuntu container and I want to ensure that my software on all these platforms will use the same driver version so I cannot…
Pejman
  • 1,328
  • 1
  • 18
  • 26
4
votes
1 answer

Linking errors when building c++ project using mongo-cxx-driver

I am currently developing a C++ application which requires the use of the mongo-cxx-driver for accessing a MongoDB instance. I attempted a couple of methods of installation, and am met with the same linker issues each time. Initially, I attempted to…
datatype_void
  • 433
  • 5
  • 23
4
votes
1 answer

MongoDB C++: Is mongocxx::pool thread safe?

Do I have to manually lock mongocxx::pool while acquiring a connection? i.e Is this safe? (example copied from Mongo website) mongocxx::instance instance{}; mongocxx::pool pool {mongocxx::uri{}}; using mongocxx::pool::entry =…
xcorat
  • 1,434
  • 2
  • 17
  • 34
4
votes
1 answer

How to retrieve the value of a specific field using mongo cxx driver

Say, I inserted the following document using the mongo command line or shell: db.Users.insert( { "user info":{ "user name" : "Joe", "password" : "!@#%$%" , "Facebook" : "aaa", "Google"…
Joe
  • 841
  • 2
  • 10
  • 25
3
votes
0 answers

bsoncxx:to_json causes double value to truncate

When I'm using bsoncxx::to_json function to convert prepared bsoncxx document to json all float/double values are truncated to 5 digits precision. Please check following code: #include #include #include…
3
votes
1 answer

Run aggregrate query in mongocxx as a string literal

In the mongocxx API, Collection.aggregate() expects a pipeline object in order to run an aggregate pipeline query. This means constructing the query by using the Pipeline class. Such as: mongocxx::pipeline p{}; …
anon9928175234
  • 105
  • 1
  • 8
1
2 3
17 18