Database update (need work later)
parent
a736478453
commit
5201824c7d
|
@ -1,9 +1,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
//#include <bsoncxx/json.hpp>
|
#include <bsoncxx/json.hpp>
|
||||||
//#include <mongocxx/client.hpp>
|
#include <mongocxx/client.hpp>
|
||||||
//#include <mongocxx/instance.hpp>
|
#include <mongocxx/instance.hpp>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
string password = db_password;
|
string password = db_password;
|
||||||
|
@ -12,27 +12,27 @@ int main() {
|
||||||
string database = "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority";
|
string database = "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority";
|
||||||
database.replace(21, 10, password);
|
database.replace(21, 10, password);
|
||||||
cout << database;
|
cout << database;
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
// // Create an instance.
|
// Create an instance.
|
||||||
// mongocxx::instance inst{};
|
mongocxx::instance inst{};
|
||||||
// const auto uri = mongocxx::uri{ "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority" };
|
const auto uri = mongocxx::uri{ "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority" };
|
||||||
// // Set the version of the Stable API on the client
|
// Set the version of the Stable API on the client
|
||||||
// mongocxx::options::client client_options;
|
mongocxx::options::client client_options;
|
||||||
// const auto api = mongocxx::options::server_api{ mongocxx::options::server_api::version::k_version_1 };
|
const auto api = mongocxx::options::server_api{ mongocxx::options::server_api::version::k_version_1 };
|
||||||
// client_options.server_api_opts(api);
|
client_options.server_api_opts(api);
|
||||||
// // Setup the connection and get a handle on the "admin" database.
|
// Setup the connection and get a handle on the "admin" database.
|
||||||
// mongocxx::client conn{ uri, client_options };
|
mongocxx::client conn{ uri, client_options };
|
||||||
// mongocxx::database db = conn["admin"];
|
mongocxx::database db = conn["admin"];
|
||||||
// // Ping the database.
|
// Ping the database.
|
||||||
// const auto ping_cmd = bsoncxx::builder::basic::make_document(bsoncxx::builder::basic::kvp("ping", 1));
|
const auto ping_cmd = bsoncxx::builder::basic::make_document(bsoncxx::builder::basic::kvp("ping", 1));
|
||||||
// db.run_command(ping_cmd.view());
|
db.run_command(ping_cmd.view());
|
||||||
// std::cout << "Pinged your deployment. You successfully connected to MongoDB!" << std::endl;
|
std::cout << "Pinged your deployment. You successfully connected to MongoDB!" << std::endl;
|
||||||
//}
|
}
|
||||||
//catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
//{
|
{
|
||||||
// // Handle errors
|
// Handle errors
|
||||||
// std::cout << "Exception: " << e.what() << std::endl;
|
std::cout << "Exception: " << e.what() << std::endl;
|
||||||
//}
|
//}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue