Index
Manage the holder's list of credentials
Description
The Index Control Plane is the interface responsible for managing CRUD operations on the holder's personal index.
If the LearnCard also implements the Cache Plane, then this method will automatically be cached!
Note: In order to use some of the methods of this plane, you will have to choose where to store the index!
You can get a list of available index providers using the providers
field:
The Index Plane implements eight methods: get
, (optionally) getPage
, (optionally) getCount
, add
, addMany
, update
, remove
, and removeAll.
index.get
Hint: You may use the "all" provider to combine the CredentialRecord
s of all providers with this method:
The get
method takes in a Mongo-style query and returns a list of CredentialRecords
, which are primarily an ID, a URI, and some metadata.
index.getPage
Note: This method is optional
If the LearnCard also implements the Cache Plane, then this method will automatically be cached!
When there are a lot of credentials stored in the index for a given query, it can be useful to paginate your queries rather than request all of them at once. That is what getPage
is for! This call will return an object of the following shape:
Using the hasMore
and cursor
fields, you can determine if you should request the next page, as well as how to request the next page. The below example shows a simple way to request all available pages:
index.getCount
Note: This method is optional
If the LearnCard also implements the Cache Plane, then this Plane will automatically be cached!
Sometimes, it can be useful for an app to display the total number of records for a given query without wanting to actual grab every credential for that query. This is where getCount
comes in handy!
index.add
The add
method takes in a CredentialRecord
and adds it to the holder's personal index.
index.addMany
The optional addMany
method takes in an array of CredentialRecord
s and adds them to the holder's personal index.
index.update
The update
method takes in an ID and an update object and updates a CredentialRecord
in the holder's personal index.
index.remove
The remove
method takes in an ID and removes the CredentialRecord
with the corresponding ID from the holder's personal index.
index.removeAll
The optional removeAll
method flushes all CredentialRecord
s from the holder's personal index.
Example plugins that implement the Index Plane
IDXLearnCloudLast updated