Qt C++ FireBase Update Unique Value
-
I have a database in FreeBase.
There is a database structure as in the photo .
When I want to make changes in the database, I need to change all the data, but I want to change only one data. The codes I wrote below update all the data.
manager = new QNetworkAccessManager();
request.setUrl(QUrl("https://xxx/Printers/Syra123/3333.json"));
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));QVariantMap newPrinter;
newPrinter["AvailableModels"] = value.getAvailableModels(); newPrinter["CurrentBedTemp"] = value.getCurrentBedTemp(); newPrinter["CurrentNozzleTemp"] = value.getCurrentNozzleTemp(); newPrinter["Percentage"] = value.getPercentage(); newPrinter["PrintedTime"] = value.getPrintTime(); newPrinter["PrinterStatus"] = value.getPrinterStatus(); newPrinter["PrintingStatus"] = value.getPrintingStatus(); newPrinter["SelectedBedTemp"] = value.getSelectedBedTemp(); newPrinter["SelectedModel"] = value.getSelectedModel(); newPrinter["SelectedNozzleTemp"] = value.getSelectedNozzleTemp(); newPrinter["SelectedPositionX"] = value.getSelectedNozzleX(); newPrinter["SelectedPositionY"] = value.getSelectedNozzleY(); newPrinter["SelectedPositionZ"] = value.getSelectedNozzleZ(); newPrinter["SelectedPrintSpeed"] = value.getSelectedPrintSpeed(); newPrinter["SelectedPrintingStatus"] = value.getSelectedPrintingStatus(); newPrinter["StartingTime"] = value.getStartingTime(); QJsonDocument jsonDoc = QJsonDocument::fromVariant(newPrinter); manager->put(request,jsonDoc.toJson());
When I write and send only one data, it destroys all other values in the database and only the data I sent remains. How can I change only the data I want without deleting the data in the DataBase?
-
Hi,
Not knowing the FreeBase API it's hard to answer. Do you have a link of it ?
In any case, the worst case scenario would be to fetch the whole data, change the fields you want and then send again the whole data.