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
2
votes
0 answers

Extract key attributes mongocxx

I am trying to extract only key attributes through mongocxx but using find() and find_one() function .I am not able to pull only key values. int main(int, char**) { mongocxx::instance inst{}; mongocxx::client conn{mongocxx::uri{}}; auto…
Shringa Bais
  • 191
  • 2
  • 11
2
votes
1 answer

move copy and/or assign a mongodb cxx cursor

I'm writing a series of classes that wrap around the mongodb-cxx classes in order to conform them to the storage API of the rest of my application, which is written in Qt. I don't need the full function set of Mongo, basically just CRUD: create,…
Eyelash
  • 1,760
  • 2
  • 12
  • 18
2
votes
1 answer

Upgrading MongoDB C++ Driver to mongocxx-3.1.2

How to upgrade from mongoDB C++ driver from Legacy to mongocxx-3.1.2 easly? What are the classes in mongocxx-3.1.2 for following? mongo::BSONElement; mongo::BSONObj; mongo::BSONObjBuilder; Thanks In Advance..
snb
  • 633
  • 1
  • 6
  • 13
2
votes
0 answers

Mongodb cxx + Unreal Engine 4 - Crash while iterating over Cursor

I got an error while or after iterating over a mongocxx::cursor after finding some documents in my database. I am using Windows 10, Unreal Engine 4.16.1 and mongodb cxx 3.1.1. The database connection is set up correctly, the find function finds my…
Marcel
  • 21
  • 3
2
votes
1 answer

Mongocxx connection error

I installed mongocxx driver successfully. Now I tried to write a class to connect and query data from database. If I write a query in constructor like this DBConnection::DBConnection() { mongocxx::instance instance{}; mongocxx::uri…
GAVD
  • 1,977
  • 3
  • 22
  • 40
2
votes
1 answer

mongoc driver: how to query based on ISOdate?

I have a simple query that worked on mongodb shell: db.collection.find({"date": {$lt: ISODate("2015-11-03T00:00:00Z")} }) very simple, just trying to find any record that has date before 2015-11-03. Now i want to translate to similar code in mongoc…
dome some
  • 479
  • 7
  • 22
2
votes
1 answer

How to generate Mongodb documents recursively using mongocxx c++ driver?

How to generate Mongodb documents recursively using mongocxx c++ driver? 1. I use mongocxx c++ driver v.3 and c++11. 2. Here is my main.cpp method, which parses hex string and generate mongocxx code like this: console:$ ./main dissect…
2
votes
0 answers

Escaping part of a regular expression in MongoDB C++ driver

I am using MongoDB 3.4 with the C++ driver (latest version, 3.1.1). I need to query for an item via $regex that starts with the given prefix. Currently, I use the following query document: auto query = bsoncxx::builder::stream::document() <<…
s3rvac
  • 9,301
  • 9
  • 46
  • 74
2
votes
1 answer

How to use insert_many() method of MongoDB in C++?

I am using a method to store some data in a MongoDB database. void save_data(std::vector< class_a > list){ using namespace std; using bsoncxx::builder::stream::document; using bsoncxx::builder::stream::finalize; std::vector<…
Shinji Ikari
  • 173
  • 1
  • 12
2
votes
1 answer

How to upload files in MongoDB through mongocxx C++ driver?

I want to use the mongo-cxx-driver to upload files but can't find a way. Tried to use the gridfs feature of mongodb but couldn't integrate. Using current stable version mongodb-cxx-driver (3.1.1). gridFs throws error when try to store file like…
Rashik
  • 93
  • 10
2
votes
1 answer

MongoCxx 3.1.0 How can I close connection?

I have program which may have few connections and I need close each one connections. Help me please. #include #include #include #include #include…
YaroslvaV
  • 85
  • 11
2
votes
1 answer

Is it possible to check if mongoDB is running from cxx driver?

I am wondering if I am able to check that if mongoDB is running from a Cxx driver. The version I am using is 3.0.1. I tired to dig into mongocxx::client and mongocxx::v_noabi::collection, but I could not find a function/method that seems to do the…
Joe
  • 841
  • 2
  • 10
  • 25
2
votes
0 answers

Append binary data into a basic document mongocxx c++

I've done some work with the legacy driver and now I'm upgrading to the new one. But I'm stuck with a problem. I'm trying to append a b_binary to a basic document, but bytes is const *uint8_t. So, I can't append variable values, just static. Is…
2
votes
1 answer

bsoncxx::to_json return corrupted string

I'm having difficulties converting a bson document to a json string using bsoncxx. The bsoncxx::to_json function return an "invalid"/corrupted std::string object.. I can't read the character in it, and it crash when the std::string is…
pascx64
  • 904
  • 16
  • 31
2
votes
0 answers

Mongocxx driver example compilation issue

I have installed mongocxx with the instructions here on Ubuntu 14.04 /usr/local/lib has libbsoncxx.so , libmongoc-1.0.so and libmongocxx.so I am using cmake to compile the simple example in the instructions cmake_minimum_required(VERSION…
avrono
  • 1,648
  • 3
  • 19
  • 40