KeyRepository
@hyperledger/identus-sdk v7.0.0
@hyperledger/identus-sdk / overview / KeyRepository
Class: KeyRepository
Defined in: src/pluto/repositories/KeyRepository.ts:7
MapperRepository
Extends BaseRepository to handle Store interactions while mapping between a Domain class and a Model object
Extends
Constructors
Constructor
new KeyRepository(
store:Store,keyRestoration:KeyRestoration):KeyRepository
Defined in: src/pluto/repositories/KeyRepository.ts:8
Parameters
| Parameter | Type | 
|---|---|
| store | Store | 
| keyRestoration | KeyRestoration | 
Returns
KeyRepository
Overrides
Methods
byUUID()
byUUID(
uuid:string):Promise<PrivateKey|null>
Defined in: src/pluto/repositories/builders/MapperRepository.ts:75
Utility fn for common use of find with uuid
Parameters
| Parameter | Type | Description | 
|---|---|---|
| uuid | string | 
Returns
Promise<PrivateKey | null>
first found Domain instance or undefined
Throws
Domain.PlutoError.StoreQueryFailed if the query fails
Inherited from
delete()
delete(
uuid:string):Promise<void>
Defined in: src/pluto/repositories/builders/BaseRepository.ts:52
Parameters
| Parameter | Type | 
|---|---|
| uuid | string | 
Returns
Promise<void>
Inherited from
find()
find(
selector?:Partial<Key>):Promise<PrivateKey[]>
Defined in: src/pluto/repositories/builders/MapperRepository.ts:48
Search for instances based on given values
Parameters
| Parameter | Type | Description | 
|---|---|---|
| selector? | Partial<Key> | object with matchable properties | 
Returns
Promise<PrivateKey[]>
all found Domain instances
Throws
Domain.PlutoError.StoreQueryFailed if the query fails
Inherited from
findOne()
findOne(
selector?:Partial<Key>):Promise<PrivateKey|null>
Defined in: src/pluto/repositories/builders/MapperRepository.ts:61
Search for single instance based on given values
Parameters
| Parameter | Type | Description | 
|---|---|---|
| selector? | Partial<Key> | object with matchable properties | 
Returns
Promise<PrivateKey | null>
first found Domain instance or null
Throws
Domain.PlutoError.StoreQueryFailed if the query fails
Inherited from
get()
get(
query?:Query<Key>):Promise<PrivateKey[]>
Defined in: src/pluto/repositories/builders/MapperRepository.ts:36
Search the Store, mapping any found to Domain
Parameters
| Parameter | Type | Description | 
|---|---|---|
| query? | Query<Key> | either an object or array of objects with matchable properties | 
Returns
Promise<PrivateKey[]>
Array of matched Domain instances
Throws
Domain.PlutoError.StoreQueryFailed if the query fails
Inherited from
getModels()
Defined in: src/pluto/repositories/KeyRepository.ts:15
Search the Store for Models
Parameters
| Parameter | Type | Description | 
|---|---|---|
| query? | Query<Key> | a Query object, a set of values and operators defining the query | 
Returns
Promise<Key[]>
Array of matched Models
See
../types.ts
Examples
search for a model with uuid and name
  repo.getModels({ selector: { uuid: "1", name: "eg" }})
search for models with uuid of 1 or 2
  repo.getModels({ selector: { $or: [{ uuid: "1" }, { uuid: "2" }] }})
search for all models
  repo.getModels()
Throws
Domain.Models if the query fails
Overrides
insert()
Defined in: src/pluto/repositories/builders/BaseRepository.ts:32
Persist the Model in the Store.
Parameters
| Parameter | Type | Description | 
|---|---|---|
| model | Key | 
Returns
Promise<Key>
Throws
Domain.PlutoError.StoreInsertError if insert fails
Inherited from
save()
save(
domain:PrivateKey):Promise<void>
Defined in: src/pluto/repositories/builders/MapperRepository.ts:89
Persist the Domain instance in the Store.
Parameters
| Parameter | Type | Description | 
|---|---|---|
| domain | PrivateKey | Will be mapped to relevant Model for persistance | 
Returns
Promise<void>
See
Throws
Domain.PlutoError.StoreInsertError if insert fails
Inherited from
toDomain()
toDomain(
model:Key):PrivateKey
Defined in: src/pluto/repositories/KeyRepository.ts:22
Map from a Model to the Domain class
Parameters
| Parameter | Type | Description | 
|---|---|---|
| model | Key | the stored Model with a uuid | 
Returns
Domain with uuid set
Overrides
toModel()
toModel(
domain:PrivateKey):Key
Defined in: src/pluto/repositories/KeyRepository.ts:35
Map from a Domain class to a Model
Parameters
| Parameter | Type | Description | 
|---|---|---|
| domain | PrivateKey | may be missing uuid | 
Returns
Model potentially without uuid
Overrides
update()
update(
model:Key):Promise<void>
Defined in: src/pluto/repositories/builders/BaseRepository.ts:43
Parameters
| Parameter | Type | 
|---|---|
| model | Key | 
Returns
Promise<void>