Getting Started with Enginio using C++
Setup Qt application project
You need to link to Enginio. For qmake-based projects simply add
QT += enginio
to your .pro file.
Initialize Enginio Client
To use the Enginio Qt library in your code, you have to include relevant library headers.
#include <Enginio/Enginio>
Before making any calls to the Enginio API, the EnginioClient needs to be instantiated. To do this, you will also need the id of the backend, which can be copied from the Dashboard. Go to the Enginio Dashboard and select a backend. Copy the backend id value.
QByteArray backendId("YOUR_OWN_BACKEND_ID"); EnginioClient *client = new EnginioClient; client->setBackendId(backendId);
For testing purposes, it is easiest to hardcode the backend id directly into application code. However, this might not be always the best choice, and sometimes it might be beneficial to put the backend configuration in a separate configuration file.
Store your first Object
Create an object in JSON format and fill in the data:
QJsonObject city; city.insert("objectType", QString("objects.city")); // an object type is required for all objects in Enginio city.insert("name", QString("Oslo")); // other properties can be chosen freely city.insert("population", 624000);
Create the object in the Enginio database by calling EnginioClient::create():
client->create(city); connect(client, SIGNAL(finished(EnginioReply*)), this, SLOT(uploadFinished(EnginioReply*)));
Note that the create() method performs the actual asynchronous network communication. You need to wait for its completion by connecting to the finished and error signals.
Now you can check the Enginio dashboard for the newly created object.