Working with KVDBs
KVDBs allow users to access key-value databases.
Each Context can contain any number of KVDBs with a unique identifier (kvdbId) used to distinguish them.
KVDBs do not need to have unique names or assigned public keys.
Permissions
KVDBs differentiate two types of users - Managers and Regular Users. The table below shows the differences in their permissions:
| Activity | User | Manager |
|---|---|---|
| Sending entries | yes | yes |
| Editing KVDB | no | yes |
| Deleting entries | only their own | all entries |
The values above are the default policy values defined by PrivMX. To read more about Policies and learn how to modify them, go to Policies.
Before working with KVDBs, follow our Getting Started Guide. It will show you how to set up your project to work with PrivMX Bridge. Sample code on this page is based on the initial assumptions.
Working with KVDBs
When working with KVDBs, you will use the following:
KvdbApi- provides methods used to manage KVDBs in given Context
Let's modify the project from the First App chapter to connect to PrivMX Bridge, create a KVDB, and set the first entry in it.
CMakeLists.txt
main.cpp
Creating KVDBs
Creating a basic, unnamed KVDB, which can act as an encrypted key-value database:
Hint: You can assign any data to private and public meta fields (e.g. the KVDB's name), as long as it is serialized and can be given as the core::Buffer.
Fetching KVDBs
Getting a list of KVDBs available for the user in the given Context:
As a result you will receive an object:
Getting a Single KVDB:
A detailed description of the Kvdb object fields can be found in API Reference.
Modifying KVDBs
To update a KVDB you must always provide a full list of parameters.
The updateKvdb(...) method needs all the parameters as in the createKvdb(...) method and a few more. If you want to update
one of the parameters – provide it in a new modified form. If, on the other hand, you want to leave
the parameter unchanged – provide it as it was before.
Deleting KVDBs
To delete a KVDB, you need to use the deleteKvdb(...) method.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.