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
1
vote
1 answer

Create bsoncxx::builder::basic::document from a string?

Is there a way to create a bsoncxx::builder::basic::document from a std::string? I know how to build a document using mongocxx functions such as make_document, kvp, make_array, as well as through the streaming functions. But what I want to know is…
Caroline Beltran
  • 888
  • 2
  • 9
  • 22
1
vote
0 answers

How to write a mongocxx query which have to retrieve the records between two time stamps?

I'm trying transalate below mongodb query into mongocxx query. db.collection.find({'order_id':'O1-0705','timestamp':{'$gte':new Date('2019-07-15 21:30:15.932'),'$lte':new Date('2019-07-15 21:35:15.932')}}) Facing error while converting timestamp as…
1
vote
2 answers

MongoDB error using transactions: Total size of all transaction operations must be less than 16793600. Actual size is 16793810: generic server error

I'm working with mongodb transactions in c++. The steps I’m performing are the following: create session create a bulk_write for this session, where I have multiple inserts to a collection start transaction execute bulk_write commit…
Federico Caccia
  • 1,817
  • 1
  • 13
  • 33
1
vote
1 answer

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
Fishish
  • 165
  • 1
  • 10
1
vote
1 answer

Is there a way to add local bson documents to mongodb using mongocxx driver?

I have a few bson files which i need to insert into the mongodb using c++ code. Is there any way to insert a bson document into mongodb using mongocxx driver? I am using ubuntu, and all I could get was to manually create the document inside the…
Ionut Grad
  • 11
  • 1
1
vote
1 answer

Unset document element in Mongo CXX

I have a class that has a bsoncxx::document::view view as a private attribute, and a method that get a document from the Mongo database and save the result in the local bsoncxx::document::value value variable and then get the view from the…
user7075574
1
vote
0 answers

MongoDB C++ Driver (mongocxx) single unresolved external symbol (mongocxx::v_noabi::uri::k_default_uri) when running test after installation

For the past two days I have tried to build and test mongocxx on two different Windows 10 machines, one using VS2015 and the other using VS2017. The builds install without errors (though I had initial issues with ENABLE_EXTRA_ALIGNMENT). However,…
M H
  • 41
  • 1
  • 6
1
vote
1 answer

How to compare the "_id" in mongodb via mongocxx?

I'm going to build a server, and i have a list containing a struct("_id" is in it), now i want to compare the _id between the exist one in mongodb and the one in instruct. I've finished the code, and when it comes to compiling, there are two same…
林新年
  • 13
  • 2
1
vote
2 answers

bsoncxx - is there a way to iterate through documents in .bson dump file?

Similarly to how we construct bsoncxx::document::view objects from a buffer with a single binary document, is there a way to extract single documents from a collection in a .bson dump in this framework without having to load them into a DB? i.e.…
1
vote
0 answers

Edit a field value of a BSON document using Mongo C++ driver

I was attempted to update a few field values of a BSON document using the Mongo C++ driver, but it seems like my implementation using $set does not work properly. mongo::BSONObj update(mongo::BSONObjBuilder b, mongo::BSONObj bson, int value) { …
Ben
  • 15
  • 3
1
vote
1 answer

MongoC++ driver BSON construction: stream-based vs. string parsing based. Which one has better performance?

The MongoDB C++ driver allows two ways (among others) of creating BSON objects. Based in stream: auto builder = bsoncxx::builder::stream::document{}; bsoncxx::document::value doc_value = builder << "name" << "MongoDB" << "type" << "database" …
fgalan
  • 11,732
  • 9
  • 46
  • 89
1
vote
2 answers

Problem with libbson version for mongocxx driver [Windows OS]

Trying to build mongocxx driver. I have installed mongoc driver without problems in path c:\mongo-c-driver (ver. 1.14.0). After running: cmake.exe -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver …
KonDziupla
  • 23
  • 3
1
vote
1 answer

mongo-cxx-driver can not iterate view

I have a mongodb collection with the following document: { "_id" : ObjectId("5c879a2f277d8132d6707792"), "a" : "133", "b" : "daisy", "c" : "abc" } When I run the following mongocxx code: auto r =…
kroiz
  • 1,722
  • 1
  • 27
  • 43
1
vote
0 answers

build mongo c driver

I'm trying to build the C driver with Kerberos support, from mongo-c-driver-1.10.3.tar.gz. I'm on Ubuntu 16.04, 64-bit Intel, with gcc 5.4.0. I run CMake like:: $ cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF .. ... -- Build files have…
leao
  • 11
  • 1
1
vote
1 answer

Access violation reading location when using mongocxx driver

I'm having some trouble with the mongodb c++ driver. I have the following code and it worked fine: //bsoncxx::document::value doc-->It was defined properly before static mongocxx::instance inst{}; mongocxx::client conn{ mongocxx::uri{} }; auto db…