Retrieve Records
To retrieve records from SecretVault, fetch data from your cluster's nodes, then decrypt any encrypted fields using nilQL to reconstruct the original data.
1. Check Your Collection for the Schema ID
List available Collections using the List Schemas endpoint (GET /schemas) to get the Schema ID of the collection you want to store your data in.
2. Retrieve Records
Retrieve records from a collection by calling the Read Data endpoint (POST /data/read
) with the schema id and optionally a filter. If you don't pass in a filter, all records will be returned.
Using a filter
A filter can be a basic match (e.g. "status": "active"
), a comparison (e.g. "age" : { "$gte": 30}
) or something more complex.
Complex filter example & resources
{
"filter": {
"$and": [
{ "status": "active" },
{ "age": { "$gte": 30 } },
{ "tags": { "$in": ["premium", "verified"] } }
]
}
}
For more operator options check out Comparison Operators and Logical Operators.
Examples for retrieving records
Example POST /data/read
Payload
{
"schema": "9b22147f-d6d5-40f1-927d-96c08XXXXXXXX",
"filter": {
"_id": "120a60f3-d1b6-4a11-a413-abcd60c8ccb3"
}
}
Code Samples
- Python
- TypeScript
- JavaScript (with wrapper)
- Python (with wrapper)
nildb/secretvault_python/nildb_api.py
loading...
nildb/secretvault_nextjs/app/lib/nildb.ts
loading...
Install secretvaults
npm i secretvaults
Run the readWriteSv script
node readWriteSv.js
- readWriteSv.js
- orgConfig.js
examples/readWriteSv.js
loading...
examples/orgConfig.js
loading...
Retrieved records will have:
- Plaintext fields with identical values across nodes
- Encrypted fields as shares that need nilQL to decrypt and reconstruct values from all nodes
Other operations on records
- Update Data endpoint (also supported via the
secretvaults
JS+Python wrappers) - Delete Data endpoint (also supported via the
secretvaults
JS+Python wrappers) - Flush Data endpoint
- Tail Data endpoint