mongo-cxx-driver

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

做~自己de王妃 提交于 2019-12-07 17:18:45
问题 This is about the new MongoDB C++ Driver (not the legacy one). I can insert a document this way: value Value = document{} <<"Key" <<"Value" <<finalize; cxxClient["db"]["collection"].insert_one(Value.view()); The above code insert a document with 1 field 'Key' of value 'Value'. I can insert string, int, float,... but just can't figure out how to insert ISODate. The new MongoDB C++ Driver should come with more examples in documentation. 回答1: Thanks Styvane, I found it out how! value Value =

How to set up Visual Studio project settings with mongo-cxx-driver?

 ̄綄美尐妖づ 提交于 2019-12-06 14:50:59
问题 I have successfully build the version 3.0.3 of the MongoDB driver for C++ on Windows 10 with CMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver But I don't know how to set up a project in Visual Studio 2015 that can use this driver. I found this post here, but I don't understand the exact solution. I tried the following properties but failed: C/C++ > Additional Include Directories: C:\mongo-c-driver\include\libbson-1.0;C:\mongo-c-driver\include\libmongoc-1.0;C:\mongo-cxx-driver\include\bsoncxx\v_noabi

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

微笑、不失礼 提交于 2019-12-06 05:30:28
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 documents and returns a valid cursor. It ends up in this Exception: Exception thrown at 0x00007FFDED56B698 (UE4Editor-Core.dll) in UE4Editor.exe: 0xC0000005: Access violation writing location 0x0000000000000010. with this output: 2598:0a50 @ 01781390 - LdrpCallTlsInitializers - INFO: Calling TLS callback 00007FFDDC66C154 for DLL "C:\WINDOWS\System32

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

折月煮酒 提交于 2019-12-05 02:32:42
问题 // 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 bsoncxx::builder::stream::array mybsonarr; for(float i = 0 ; i < 5 ; i = i + 0.1f){ mybsonarr << i; } // Now this line Throws an error data_builder << "_id" << 5 << "my_array" << &mybsonarr; So how can I add my array and also how can I read back my float array to either and array or vector ? 回答1

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

依然范特西╮ 提交于 2019-12-03 17:16:21
// 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 bsoncxx::builder::stream::array mybsonarr; for(float i = 0 ; i < 5 ; i = i + 0.1f){ mybsonarr << i; } // Now this line Throws an error data_builder << "_id" << 5 << "my_array" << &mybsonarr; So how can I add my array and also how can I read back my float array to either and array or vector ? For adding array to stream document use open_array : using bsoncxx::builder::stream::document; using

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

╄→гoц情女王★ 提交于 2019-12-01 11:33:47
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 source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. code is in test.cc file #include <iostream> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/json.hpp> #include <mongocxx/client.hpp> #include <mongocxx/instance.hpp> int main(int, char**) { mongocxx::instance inst{};

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

一个人想着一个人 提交于 2019-12-01 08:20:59
问题 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 source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. code is in test.cc file #include <iostream> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/json.hpp> #include