1 files changed, 22 insertions, 4 deletions
diff --git a/src/mongoStub.cpp b/src/mongoStub.cpp
index 50312fc6..3e7ae3df 100644
--- a/src/mongoStub.cpp
+++ b/src/mongoStub.cpp
@@ -17,10 +17,28 @@ mongoStub::mongoStub() {
}
}
-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));
+//Too slow for my liking
+std::vector<mongoStub::mongoMessage> mongoStub::getNewMessages(mongocxx::change_stream* colCs) {
+ std::vector<mongoStub::mongoMessage> retVec;
+
+ for (auto&& event : *colCs) {
+ mongoStub::mongoMessage returnValue;
+
+ /*if(event["fullDocument"]["data"]){
+ returnValue.data.push_back(event["fullDocument"]["data"].get_utf8().value.to_string());
+ }*/
+
+
+
+ std::cout << bsoncxx::to_json(event) << std::endl;
+
+ //Oly listen to insert events (to avoid "precondition failed: data" exception)
+ if(event["operationType"].get_utf8().value.to_string()!="insert"){
+ continue;
+ }
+ returnValue.eventName = event["fullDocument"]["event"].get_utf8().value.to_string();
+ retVec.push_back(returnValue);
}
+
return retVec;
}
|