Skip to content

Class: DIDDataStore<ModelTypes, Alias>

did-datastore.DIDDataStore

import { DIDDataStore } from '@glazed/did-datastore'

Type parameters

Name Type
ModelTypes extends ModelTypeAliases``ModelTypeAliases
Alias extends keyof ModelTypes["definitions"]keyof ModelTypes["definitions"]

Constructors

constructor

new DIDDataStore<ModelTypes, Alias>(__namedParameters)

Type parameters

Name Type
ModelTypes extends ModelTypeAliases<Record<string, any>, Record<string, string>, Record<string, string>>ModelTypeAliases<Record<string, any>, Record<string, string>, Record<string, string>>
Alias extends string | number | symbolkeyof ModelTypes["definitions"]

Parameters

Name Type
__namedParameters DIDDataStoreParams<ModelTypes>

Accessors

authenticated

get authenticated(): boolean

Returns

boolean


ceramic

get ceramic(): CeramicApi

Returns

CeramicApi


id

get id(): string

Returns

string


model

get model(): DataModel<ModelTypes, ModelTypesToAliases<ModelTypes>>

Returns

DataModel<ModelTypes, ModelTypesToAliases<ModelTypes>>

Methods

get

get<Key, ContentType>(key, did?): Promise<null | ContentType>

Type parameters

Name Type
Key extends string | number | symbol
ContentType DefinitionContentType<ModelTypes, Key>

Parameters

Name Type
key Key
did? string

Returns

Promise<null | ContentType>


getDefinition

getDefinition(id): Promise<DefinitionWithID<Record<string, unknown>>>

Parameters

Name Type
id string | StreamID

Returns

Promise<DefinitionWithID<Record<string, unknown>>>


getDefinitionID

getDefinitionID(aliasOrID): string

Parameters

Name Type
aliasOrID string

Returns

string


getIndex

getIndex(did?): Promise<null | IdentityIndex>

Parameters

Name Type
did? string

Returns

Promise<null | IdentityIndex>


getRecord

getRecord<ContentType>(definitionID, did?): Promise<null | ContentType>

Type parameters

Name Type
ContentType unknown

Parameters

Name Type
definitionID string
did? string

Returns

Promise<null | ContentType>


getRecordDocument

getRecordDocument(definitionID, did?): Promise<null | TileDoc>

Parameters

Name Type
definitionID string
did? string

Returns

Promise<null | TileDoc>


getRecordID

getRecordID(definitionID, did?): Promise<null | string>

Parameters

Name Type
definitionID string
did? string

Returns

Promise<null | string>


has

has(key, did?): Promise<boolean>

Parameters

Name Type
key Alias
did? string

Returns

Promise<boolean>


iterator

iterator(did?): AsyncIterableIterator<Entry>

Parameters

Name Type
did? string

Returns

AsyncIterableIterator<Entry>


merge

merge<Key, ContentType>(key, content, options?): Promise<StreamID>

Type parameters

Name Type
Key extends string | number | symbol
ContentType DefinitionContentType<ModelTypes, Key>

Parameters

Name Type
key Key
content ContentType
options? CreateOptions

Returns

Promise<StreamID>


remove

remove(key): Promise<void>

Parameters

Name Type
key Alias

Returns

Promise<void>


set

set<Key, ContentType>(key, content, options?): Promise<StreamID>

Type parameters

Name Type
Key extends string | number | symbol
ContentType DefinitionContentType<ModelTypes, Key>

Parameters

Name Type
key Key
content ContentType
options? CreateOptions

Returns

Promise<StreamID>


setAll

setAll<Contents>(contents, options?): Promise<IdentityIndex>

Type parameters

Name Type
Contents extends DefinitionsContentTypes<ModelTypes, Record<string, unknown>>

Parameters

Name Type
contents Contents
options? CreateOptions

Returns

Promise<IdentityIndex>


setDefaults

setDefaults<Contents>(contents, options?): Promise<IdentityIndex>

Type parameters

Name Type
Contents extends DefinitionsContentTypes<ModelTypes, Record<string, unknown>>

Parameters

Name Type
contents Contents
options? CreateOptions

Returns

Promise<IdentityIndex>


setRecord

setRecord(definitionID, content, options?): Promise<StreamID>

Parameters

Name Type
definitionID string
content Record<string, any>
options? CreateOptions

Returns

Promise<StreamID>