summary refs log tree commit diff
path: root/src/mongoStub.cpp
blob: 50312fc63ff3300062a18fd1a7a747a52c6af477 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}