I'm using the mongocxx driver in a project which is powered by Qt 5.11. Because there are only a few articles about it on the internet, I couldn't find a solution to my problem: I'm trying to connect and get data from my Mongo database but multiple times with slots. Here's an example of what I'm trying to do:
#include "mainwindow.h"
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
MainWindow::MainWindow() : QMainWindow() {
mongocxx::instance *inst{}; //shouldn't be done twice
mongocxx::client conn{mongocxx::uri{}}; //this neither
bsoncxx::builder ::stream::document *document{};
//doingStuffWithoutMongo();
//then
LoadClients();
GetAndSetBanks();
}
void MainWindow::LoadClients() {
//doingStuffAndGettingDataFromMongo();
auto collection = conn[awesomeDatabase][awesomeCollection]; //use of undeclared identifier 'conn'
}
void MainWindow::GetAndSetBanks() {
//doingStuffAndGettingDataFromMongo();
auto collection = conn[awesomeDatabase][awesomeCollection]; //use of undeclared identifier 'conn'
}
I need the identifier 'conn' in both of my slots but I can't call it more than once. I also tried to declare it in my mainwindow.h
file but i'm getting this error:
Maybe I'm declaring something wrong, I don't know, I'm not at ease with this language yet, if somebody could help me, I would be glad to accept her/his answer.
Aucun commentaire:
Enregistrer un commentaire