PrivMX DOCS
C++

KVDB Entries

Setting Entries in KVDB.

Sample code on this page is based on the initial assumptions.

Entries Inside KVDB

Entries inside KVDBs are set in binary format. Before creating an entry, you need to decide on the entry format.

For more information about the KVDB's architecture and best practices for creating entries, visit the KVDBs Documentation.

Creating/Updating Entry

Creating/updating a simple entry to the given KVDB:

// ...

// creating/updating entry to the KVDB represented by its kvdbId,
// When you create entry ENTRY_VERSION must be set to 0. When updating it myst be set to current version of given entry
kvdbApi.setEntry(
    kvdbId, 
    "entry key"
    core::Buffer::from("some public meta-data"), 
    core::Buffer::from("some private meta-data"), 
    core::Buffer::from("serialized entry data"),
    ENTRY_VERSION 
);

// ...

Listing All Keys in KVDB

To get a list of Entry Keys inside a KVDB, use listEntriesKeys method. Reading the entry keys of the KVDB (limited to the 100 newest entries as described by the KvdbKeysPagingQuery object):

// ...

auto entriesKeys {kvdbApi->listEntriesKeys(
    kvdbId,
    kvdb::KvdbKeysPagingQuery{
        .skip=0, 
        .limit=100, 
        .sortOrder="desc"
    }
)};
for (auto keys: entriesKeys.readItems) {
    std::cout << "key: " << keys << std::endl;
}

// ...

Getting Entry in KVDB

To get an Entry inside a KVDB, use getEntry method.

// ...

auto entry {kvdbApi->getEntry(
    kvdbId,
    entry_key
)};

// ...

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