IDX SDK Reference¶
Installation¶
npm install @ceramicstudio/idx
IDX class¶
constructor¶
Arguments:
.authenticated¶
Returns whether a DID is currently authenticated.
Returns: boolean
.ceramic¶
Returns: CeramicApi
.id¶
Returns the DID of the currently authenticated user.
Accessing this property will throw an error if the instance is not authenticated.
Returns: string
.has()¶
Returns whether a record exists in the index for a given DID.
Arguments:
Returns: Promise<boolean>
.get()¶
Returns a record in the index for a given DID.
Arguments:
Returns: Promise<unknown>
.set()¶
Sets or modifies a record in the index of the authenticated DID.
Arguments:
name: string
(alias or IndexKey)content: unknown
options?: CreateOptions
(only applied if the document is being created, if it already exists they are ignored)
Returns: Promise<DocID>
the recordID of the created record
.merge()¶
Performs a shallow (one level) merge to a record in the index of the authenticated DID.
Arguments:
name: string
(alias or IndexKey)content: unknown
options?: CreateOptions
(only applied if the document is being created, if it already exists they are ignored)
Returns: Promise<DocID>
the recordID of the created record
.setAll()¶
Similar to the .set()
method but for setting multiple records at once in a more efficient way.
The index will only get updated if all records are successfully set.
Arguments:
contents: Record<string, unknown>
options?: CreateOptions
(only applied if the document is being created, if it already exists they are ignored)
Returns: Promise<Record<string, string>>
the recordIDs of the created records
.setDefaults()¶
Similar to the .setAll()
method but only sets records for keys that are not already present in the index.
contents: Record<string, unknown>
options?: CreateOptions
(only applied if the document is being created, if it already exists they are ignored)
Returns: Promise<Record<string, string>>
the recordIDs of the created records
.remove()¶
Removes a definitionID:recordID pair from the index of the authenticated DID.
Arguments:
Returns: Promise<void>
.getIndex()¶
Returns the index for the given DID.
This method can be used to get the full definitionID:recordID mapping at once
Arguments:
did?: string = this.id
Returns: Promise<Index | null>
.iterator()¶
Returns an async iterator of Entry
for the given DID.
This method can be used to iteratively load all the records in the index
Arguments: å
did?: string = this.id
Returns: AsyncIterableIterator<Entry>
.getDefinition()¶
Loads a definition.
Arguments:
Returns: Promise<DefinitionWithID>