Queries
Last updated
Was this helpful?
Last updated
Was this helpful?
The majority of decentralized data solutions in the Web3 space provide simple key
/ value
storage options as querying distributed and / or encrypted databases is a significantly hard problem.
The Verida Client SDK architecture has the following features that facilitate querying of encrypted data in a consistent manner across many distributed databases:
Using CouchDB
compatible database synchronization and merging
Using common JSON schemas to ensure data consistency between distributed applications
Encrypt / Decrypt data on the fly between multiple CouchDB
compliant database backends, with different encryption keys for each
As a result, all applications implementing the Verida Client SDK support querying user data as you would expect from a typical NoSQL database.
Example: Fetch all runs a user has completed in 2018
Databases and datastores support a full range of query functionality. This includes; filters, limit, offset and sort:
Here's another example using a regular expression to match all records with a name that has ri
:
The following strategies allow you to paginate data for a user based on a name
field:
We received the first 10 documents sorted by name. We can continue paginating by using the last value as our next starting point. At any given point in time, we will only have 10 documents stored in the memory, which is great for performance.
You can learn more about the query functionality in the official .
Sorting only works if an index has been defined for the field being sorted. Indexes are defined in the datastore schema. See and for more details.
You can manually create database indexes by utilizing the underlying :
Datastore indexes are defined in the underlying JSON schema document for the datastore. These indexes are automatically managed by Verida Datastore. See and for more details.