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
3
votes
1 answer

mongocxx how to build a document from a view?

auto cursor = db["friend"].find({}); for (auto &&docView : cursor) { bsoncxx::builder::basic::document document1; document1.append(docView); // This line will be an error document1.append(kvp("surl", "http://xxx")); …
H.He
  • 55
  • 5
3
votes
1 answer

Iterate through a mongocxx query to get each key and value

I am querying a collection with the following code: bsoncxx::stdx::optional query_result = collection.find_one(bsoncxx::builder::stream::document{} << "_tablename" << tableToSearch.toUtf8().constData() << "rowuuid" <<…
QLands
  • 2,424
  • 5
  • 30
  • 50
3
votes
2 answers

Installing Mongo c and c++ drivers in Docker

I'm attempting to install the mongocxx driver in a Docker container, and step number one is to install the mongo-c driver using package manager. My slimmed down Dockerfile: FROM phusion/baseimage:latest RUN apt-get install -y libmongoc-1.0-0 After…
Nate Roiger
  • 325
  • 2
  • 7
3
votes
2 answers

How to send regular expression via in a mongoDB query using mongocxx?

Following is a piece of code where I am trying to query mongodb using mongocxx driver. /*Code for finding all that match the filter */ mongocxx::cursor cursor = collection.find( document{} << "Vehicle_Registration" << vReg << "Vehicle_Make"…
Programmer
  • 31
  • 2
3
votes
1 answer

g++ cannot static link libmongcxx(r3.0.2) but dynamic link works

I use the example code from mongodb site to show the problem here. OS: ArchLiux, c++ is a link to g++ [dean@dell_xps_13 ~]$ c++ --version c++ (GCC) 6.2.1 20160830 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the …
Dean Chen
  • 3,800
  • 8
  • 45
  • 70
3
votes
1 answer

mongocxx cursor and rvalue references

I was looking to the mongocxx query exemples and I don't get whats the point of using auto&& over auto& here. auto cursor = db["restaurants"].find({}, opts); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) <<…
MokaT
  • 1,416
  • 16
  • 37
3
votes
1 answer

Insert JSON into Mongocxx

I'm currently trying to insert a JSON file into my mongoDB. I've already seen that this was solved by making use of the mongo::BSONObj in the past... But this doesnt seem to be an option since they released the new mongocxx driver for c++11. This is…
cylex
  • 45
  • 1
  • 6
3
votes
1 answer

How to set up project with mongodb-cxx-driver in Visual Studio

I have successfully built the new libmongo-cxx-driver on Windows with Visual Studio, but I fail understanding how I can set up a project in VS 2015 to link to it. I would appreciate some help on that.
MatsB
  • 91
  • 1
  • 6
3
votes
1 answer

make mongo-cxx-driver cannot find includes

I've been trying to compile the mongo-cxx-driver for C++11 on OSX 10.10, but I have some trouble with it. Both libbson and mongo-c-driver were built and installed successfully, the libraries to to /usr/local/lib, and the headers to…
IndyStef
  • 747
  • 1
  • 6
  • 15
3
votes
1 answer

MongoDB C++ Driver 3.0 get document in string and avoid json

I am trying to get double type data from the database as the documentation says: auto cursor = db["collection"].find({}, opts); for (auto&& doc : cursor) { std::cout << bsoncxx::to_json(doc) << std::endl; } But I want to avoid converting doc…
debihiga
  • 246
  • 2
  • 10
3
votes
1 answer

MongoDB 3.2 c++ drivers , using $exists

bsoncxx::builder::stream::document search_builder; mongocxx::options::find img_find; // This speeds up the queries search_builder_images.clear(); search_builder_images << "_id" << "abc" << "data" << open_document <<"$exists" << true <<…
3
votes
1 answer

Adding a BSON Array to a MongoDB 3.2 document and extracting the values back ( MongoCXX 3.2 ) ( C++ 11)

// The document I want to add data to and extract it back from c++ bsoncxx::builder::stream::document data_builder, // I want to try and save this array in my document , as I want to populate it later …
2
votes
1 answer

Mongocxx change_stream callback

I have a process that is monitoring a mongo db and needs to be notified when there is a change to a table. It seems like the most logical way to handle this is via a change_stream with a callback that executes when something has changed - that is,…
2
votes
0 answers

Getting "could not start SASLPrep for password: generic server error" error when trying to insert/find documents in mongoDB in C++

I have a mongDB running in my VM (Ubuntu) in access control mode. I created an admin user with this role: roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] I installed the mongoDB driver for C++ and wrote a…
2
votes
1 answer

How to use mongocxx with inline namespaces and PIMPL idiom?

I want to write an interface to mongocxx using the PIMPL idiom. The interface itself works but I did something wrong with mongocxx inline namespaces because writing tests is not working. This is a minimal example: MongoInterface.h: #pragma…
gk017
  • 87
  • 1
  • 10
1
2
3
17 18