Overview
KVDBs provide encrypted key-value databases.
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 with the addition of the following values:
Working with KVDBs
To access KVDBs methods, get the field kvdbApi
from the active endpointSession
. Session should be initialized with [.kvdb]
and passed to PrivMXEndpoint
.
You can use a guard let statement to ensure the kvdbApi field is not null and avoid having to deal with optionals.
In the below code snippets we assume that kvdbApi
has been assigned like this.
Creating KVDBs
Creating a basic KVDB, which acts as an encrypted key-value database:
Fetching KVDBs
Getting a list of KVDBs available for the user in the given Context:
As a result you will receive a privmx.KvdbsList
object.
Getting a single KVDB:
A detailed description of the Kvdb
object fields can be found in API Reference.
Modifying KVDBs
How Updates Work
To update a KVDB you must always provide a full list of parameters.
The updateKvdb(_:atVersion:replacingUsers:replacingManagers:replacingPublicMeta:replacingPrivateMeta:force:forceGenerateNewKey:)
method needs all the parameters as in the createKvdb(in:for:managedBy:withPublicMeta:withPrivateMeta:)
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, use deleteKvdb(_:)
method.
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.