Store
@hyperledger/identus-sdk v8.0.0
@hyperledger/identus-sdk / overview / Pluto / Store
Interface: Store
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:73
Store interface for Pluto persistence layer
This interface defines the contract for database operations on Models. Implementations must handle CRUD operations for all supported model types.
Supported Models:
- Models.Credential - Verifiable credentials
- Models.CredentialMetadata - Metadata for credential schemas
- Models.DID - Decentralized identifiers
- Models.Key - Private keys
- Models.Message - DIDComm messages
- Models.DIDKeyLink - Links between DIDs and keys
- Models.DIDLink - Links between DIDs (pairs, mediators, routing)
Supported Tables:
- "credentials" - Stores credential data
- "credential-metadata" - Stores credential metadata
- "dids" - Stores DID documents
- "keys" - Stores private keys
- "messages" - Stores DIDComm messages
- "didkey-link" - Stores DID-key relationships
- "did-link" - Stores DID-DID relationships
Methods
delete()
delete(
table: keyofCollectionMap,uuid:string):Promise<void>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:193
Delete a row from the Store
Parameters
| Parameter | Type | Description |
|---|---|---|
table | keyof CollectionMap | Valid table name. Must be one of: "credentials", "credential-metadata", "didkey-link", "did-link", "dids", "keys", "messages" |
uuid | string | The unique identifier of the record to delete |
Returns
Promise<void>
Promise that resolves when the record is successfully deleted
Examples
Delete a credential by its uuid
await store.delete("credentials", "credential-123");
Delete a DID by its uuid
await store.delete("dids", "did:example:123");
Throws
Error if the record with the given uuid is not found or table name is not recognized
insert()
insert<
K>(table:K,model:CollectionMap[K]):Promise<void>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:144
Persist new data in the Store.
Type Parameters
| Type Parameter | Description |
|---|---|
K extends keyof CollectionMap | Valid table name. Must be one of: "credentials", "credential-metadata", "didkey-link", "did-link", "dids", "keys", "messages" |
Parameters
| Parameter | Type | Description |
|---|---|---|
table | K | The table name |
model | CollectionMap[K] | The model instance to persist. Must include all required properties and should have a valid uuid |
Returns
Promise<void>
Promise that resolves when the model is successfully persisted
Example
Insert a new credential
const credential: Models.Credential = {
uuid: "credential-123",
recoveryId: "jwt",
dataJson: JSON.stringify(credentialData),
id: "credential-id",
issuer: "did:example:issuer"
};
await store.insert("credentials", credential);
Throws
Error if the model is invalid or table name is not recognized
query()
query<
K>(table:K,query?:Query<CollectionSchemas[K]>):Promise<CollectionMap[K][]>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:119
Run a query to fetch data from the Store
Type Parameters
| Type Parameter |
|---|
K extends keyof CollectionMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
table | K | Valid table name. Must be one of: "credentials", "credential-metadata", "didkey-link", "did-link", "dids", "keys", "messages" |
query? | Query<CollectionSchemas[K]> | Optional Query object with selector conditions and operators for filtering results Query behavior: - Properties within an object will be AND'ed together - Different objects in $or array will be OR'd together - Omit query parameter to fetch all records from the table |
Returns
Promise<CollectionMap[K][]>
Promise resolving to array of models matching the query criteria
Examples
Search for credentials by uuid and issuer
store.query<Models.Credential>("credentials", {
selector: { uuid: "credential-123", issuer: "did:example:issuer" }
})
Search for DIDs with method "prism" OR "peer"
store.query<Models.DID>("dids", {
selector: { $or: [{ method: "prism" }, { method: "peer" }] }
})
Fetch all messages from the table
store.query<Models.Message>("messages")
start()?
optionalstart():Promise<void>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:78
Handle any necessary startup. Will be called first before any usage, if provided.
Returns
Promise<void>
stop()?
optionalstop():Promise<void>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:83
Handle any necessary teardown.
Returns
Promise<void>
update()
update<
K>(table:K,model:CollectionMap[K]):Promise<void>
Defined in: packages/lib/sdk/src/pluto/Pluto.ts:170
Update an existing row in the Store
Type Parameters
| Type Parameter | Description |
|---|---|
K extends keyof CollectionMap | Valid table name. Must be one of: "credentials", "credential-metadata", "didkey-link", "did-link", "dids", "keys", "messages" |
Parameters
| Parameter | Type | Description |
|---|---|---|
table | K | The table name |
model | CollectionMap[K] | The model instance with updated data. Must include the uuid to identify the record to update |
Returns
Promise<void>
Promise that resolves when the model is successfully updated
Example
Update a credential to mark it as revoked
const updatedCredential: Models.Credential = {
uuid: "credential-123",
recoveryId: "jwt",
dataJson: JSON.stringify(updatedCredentialData),
id: "credential-id",
issuer: "did:example:issuer",
revoked: true
};
await store.update("credentials", updatedCredential);
Throws
Error if the model with the given uuid is not found or table name is not recognized