PrivMX DOCS
Version 2.5/Kvdbs

Managing Entries

The structure of entries, how to send them, and good practices when working with KVDBs.

About Entries

The structure of an entry and a brief description of its elements is outlined in the following table:

FieldTypeEncryptedDescription
databinaryyescontent of the entry
infoServerKvdbEntryInfonoadditional information assigned by the server e.g. author, creationDate, key and kvdbID
privateMetabinaryyesadditional information about the entry
publicMetabinarynoadditional public information about the entry, also accessible through PrivMX Bridge API

Define Structure

KVDB's architecture does not require you to use a specific data structure inside the entry. So before working with KVDBs, define what what kind of entries you want to send.

We recommend future-proofing your entries right from the start, i.e. choosing an easily modifiable format.

It is also a good idea to include its type and version in the structure of the entries.

Here is an example entries structure that you can use in your project.

JSON
{
   “data”:{
     “content”: "string", // string / binary data containing for example: markdown, html or json
   },
   “info”: "ServerKvdbEntryInfo", // assigned by server,
   “publicMeta”:{
     “version”:number,
     “type”: “text”, // some kind of enum describing type of entry like “event”, “html”, “markdown” etc.
   },
   “privateMeta”:{
     // meta fields
   }
}

Remember that it is only an example and you should consider your app's requirements and limitations.

Sending

With the structure ready, its time to start creating entries.

Remember that before creating anything, you have to be connected to PrivMX Bridge - using connect.

// creating entry
std::string entry_key {"entry key"};
kvdbApi.setEntry(
  kvdbId, 
  entry_key,
  core::Buffer::from("some public meta-data"), 
  core::Buffer::from("some private meta-data"),
  core::Buffer::from("entry_data"),
  0
);
// read created entry
// get new KVDB 
auto entry = kvdbApi.getEntry(
  kvdbId,
  entry_key
);
// update created entry 
kvdbApi.setEntry(
  kvdbId, 
  "entry key",
  entry.privateMeta, 
  entry.privateMeta,
  core::Buffer::from("new_entry_data"),
  entry.version
);

After creating the entry, you can get it by the key set while creation.

Entry Keys are unique within a KVDB.

Using Entry Metadata

Metadata fields inside entries make it easier to integrate KVDBs into new and existing projects. KVDBs are scheme agnostic by design, which makes them easy to integrate into any application. Metadata also allows developers to add any functionalities required by their app.

PrivateMeta

privateMeta includes additional sensitive information about the entry. It's useful when you need to include the user's private data (activity details) in the entry.

Like the content of the entry itself, privateMeta is encrypted before sending. Since it is saved as binary data, you are free to choose any format. It can be a JSON parsed to a binary array or a more efficient binary format such as Protocol Buffers.

PublicMeta

Unlike privateMeta, publicMeta is not encrypted. It's useful when you want to include some additional info that does not require encryption.

publicMeta also does not have a specified structure and supports any binary format.

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.

On this page