Storing data in the database

Only JSON objects can be stored as strings using the function eventrecorder_store:

Example:

client->eventrecorder_store("{ \"param1\":1, \"param2\":\"2\" }");

 

When storing this data in the database, the current timestamp is added and also returned in the result of this command, e.g.

{"result":{"ts": 1653397060000000},"error":null,"id":0}

The time stamp has the format unix time with milliseconds.

 

Reading data from the database and filtering the results

The function eventrecorder_request can be used with a string containing a JSON object as a request for the database.

This example will give out all data stored in the database (stored in its universal table):

client->eventrecorder_request("{\"operation\":\"select\",\"table\":\"universal\",\"filter\":{\"method\":\"include_ids\",\"ids\":[9]}, \"jsonfilter\":{} } ");

 

It is also possible to call this function with a time range (minimum and maximum time stamp) of is entries:

timeval ts_min = {}, ts_max = {};

client->eventrecorder_request(ts_min, ts_max, "{  }");

Time stamps of 0 are ignored.

 

As a last parameter a JSON object can be given which is used for filtering the results.

 

Let this be the results of all data sets stored in the database:

{"result":{"eins":1,"zwei":2,"drei":3},"error":null,"id":9}

{"result":{"eins":5,"zwei":5,"drei":5},"error":null,"id":9}

{"result":{"eins":6,"zwei":6,"drei":6},"error":null,"id":9}

{"result":{"eins":8,"zwei":8,"drei":8},"error":null,"id":9}

{"result":{"param1":1,"param2":"2"},"error":null,"id":9}

{"result":{"eins":1,"zwei":2,"drei":3},"error":null,"id":9}

 

To filter for all data sets containing the parameter “eins” with values from 2 to 7 you can use this filter:

client->eventrecorder_request(ts, ts, "{ \"eins\":{\"min\":2, \"max\":7} }");

{"result":{"eins":5,"zwei":5,"drei":5},"error":null,"id":9}

{"result":{"eins":6,"zwei":6,"drei":6},"error":null,"id":9}

 

All elements in the JSON filter object have to be objects, too, as “eins” in the example above.

Integer values can be filtered using the filters “min” and “max”.

 

Boolean values can be filtered using the filters “equals”, e.g.

client->eventrecorder_request(ts, ts, "{ \"boolparameter\":{\"value\":true} }");

 

String values can be filtered using the filters “equals” and “contains”, e.g.

client->eventrecorder_request(ts, ts, "{ \"stringparameter\":{\"equals\":”test”} }");

 

Several filters can be combined in one filter object.
