From a5d98b9dccc149e75161b33ea3d1c4121029747f Mon Sep 17 00:00:00 2001 From: Newe Date: Mon, 24 May 2021 17:46:50 +0200 Subject: [edit] Deprecate gRPC in favor of MongoDB --- src/mongoStub.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/mongoStub.cpp (limited to 'src/mongoStub.cpp') diff --git a/src/mongoStub.cpp b/src/mongoStub.cpp new file mode 100644 index 00000000..50312fc6 --- /dev/null +++ b/src/mongoStub.cpp @@ -0,0 +1,26 @@ +#include "mongoStub.hpp" + +mongoStub::mongoStub() { + if (this->client) { + this->db = client["fosscord"]; + + if (this->db) { + this->col = db["events"]; + + } else { + std::cout << "db not found"; + exit(-1); + } + } else { + std::cout << "Client couldn't be initialized"; + exit(-1); + } +} + +std::vectormongoStub::getNewMessages(mongocxx::change_stream* colCs) { + std::vector retVec; + for (const auto& event : *colCs) { + retVec.push_back(bsoncxx::to_json(event)); + } + return retVec; +} -- cgit 1.5.1