使用mongodb sdk

代碼:

#include
#include

//...
mongocxx::instance inst{
     }; // This should be done only once.
mongocxx::client conn{
     
   mongocxx::uri{
     
      "mongodb+srv://:@/test?retryWrites=true&w=majority"
   }
};
mongocxx::database db = conn["test"];

在CMakeLists中加入find_package(libmongocxx REQUIRED)
如果報錯fatal error 找不到xxx時,進入usr/local中修改頭文件的目錄就好;

你可能感兴趣的:(数据库,mongodb)