summary refs log tree commit diff
path: root/src/mongoStub.cpp
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-24 17:51:06 +0200
committerGitHub <noreply@github.com>2021-05-24 17:51:06 +0200
commit2e1a821601299f212df414262defaf72edbeaa67 (patch)
tree626afe93c2bf9ad7176964f4beb70f2059daf798 /src/mongoStub.cpp
parentMerge pull request #19 from ItsNewe/master (diff)
parent[edit] Deprecate gRPC in favor of MongoDB (diff)
downloadserver-2e1a821601299f212df414262defaf72edbeaa67.tar.xz
Merge pull request #20 from ItsNewe/master
[edit] Deprecate gRPC in favor of MongoDB
Diffstat (limited to 'src/mongoStub.cpp')
-rw-r--r--src/mongoStub.cpp26
1 files changed, 26 insertions, 0 deletions
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::vector<std::string>mongoStub::getNewMessages(mongocxx::change_stream* colCs) { + std::vector<std::string> retVec; + for (const auto& event : *colCs) { + retVec.push_back(bsoncxx::to_json(event)); + } + return retVec; +}