Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IndexClient<IndexCanisterType>

Client used to interact with the CanDB Index Canister

example
import { IndexClient } from 'candb-client-typescript';
import { IndexCanister } from "../project/src/declarations/index/index.did"; // from generated index canister declaration files
import { idlFactory as MyIndexCanisterIDL } from "../project/src/declarations/index"; // from generated index canister declaration files

const indexClient = new IndexClient<IndexCanister>({
IDL: IndexCanisterIDL,
canisterId: <insert_index_canister_id>,
agentOptions: {
host: <insert_host>,
identity: <insert_identity>
},
});

Type Parameters

Hierarchy

  • IndexClient

Index

Constructors

  • Type Parameters

    Parameters

    • options: { IDL: InterfaceFactory; actorConfig?: ActorConfig; agentOptions: HttpAgentOptionsSyncIdentity; canisterId: string }
      • IDL: InterfaceFactory

        The IDL of the index canister, should match the {@link IndexCanisterType}

      • Optional actorConfig?: ActorConfig

        Optional actor configuration for interfacing with the index canister

      • agentOptions: HttpAgentOptionsSyncIdentity

        HttpAgent options for interfacing with the index canister

      • canisterId: string

        The canisterId of the index canister

    Returns IndexClient<IndexCanisterType>

Properties

indexCanisterActor: ActorSubclass<IndexCanisterTypeWrapper<IndexCanisterType>>

Actor used for directly calling methods of the index canister

Methods

  • getCanistersForPK(PK: string, useCache?: boolean): Promise<string[]>
  • Retrieves a list of canisterIds associated with the provided PK

    Parameters

    • PK: string

      The partition key

    • useCache: boolean = false

      The IndexClient stores a cache of PK to list of canisterIds. By default, the cache is not used and requests are made to the index canister. It is not recommended to use the cache when making update calls

    Returns Promise<string[]>

  • getIdentity(): Identity
  • upgradeIndexCanister(wasmModule: number[], args?: number[]): Promise<undefined>
  • Upgrades the index canister

    Calls the management canister install_code method with mode = upgrade and the provided wasm and arguments

    Parameters

    • wasmModule: number[]

      The "Blob-ified" wasm module that will upgrade the index canister

    • args: number[] = []

      any arguments to be passed along with the upgrade

    Returns Promise<undefined>

Generated using TypeDoc