langchain.js
    Preparing search index...

    Hierarchy

    • BaseClient
      • StoreClient
    Index

    Constructors

    Properties

    apiUrl: string
    asyncCaller: AsyncCaller
    defaultHeaders: Record<string, HeaderValue>
    onRequest?: RequestHook
    timeoutMs: undefined | number

    Methods

    • Delete an item.

      Parameters

      • namespace: string[]

        A list of strings representing the namespace path.

      • key: string

        The unique identifier for the item.

      Returns Promise<void>

      Promise

    • Type Parameters

      • T

      Parameters

      • path: string
      • options: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            signal?: AbortSignal;
            timeoutMs?: null | number;
            withResponse: true;
        }

      Returns Promise<[T, Response]>

    • Type Parameters

      • T

      Parameters

      • path: string
      • Optionaloptions: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            signal?: AbortSignal;
            timeoutMs?: null | number;
            withResponse?: false;
        }

      Returns Promise<T>

    • Retrieve a single item.

      Parameters

      • namespace: string[]

        A list of strings representing the namespace path.

      • key: string

        The unique identifier for the item.

      • Optionaloptions: { refreshTtl?: null | boolean }
        • OptionalrefreshTtl?: null | boolean

          Whether to refresh the TTL on this read operation. If null, uses the store's default behavior.

      Returns Promise<null | Item>

      Promise

      const item = await client.store.getItem(
      ["documents", "user123"],
      "item456",
      { refreshTtl: true }
      );
      console.log(item);
      // {
      // namespace: ["documents", "user123"],
      // key: "item456",
      // value: { title: "My Document", content: "Hello World" },
      // createdAt: "2024-07-30T12:00:00Z",
      // updatedAt: "2024-07-30T12:00:00Z"
      // }
    • List namespaces with optional match conditions.

      Parameters

      • Optionaloptions: {
            limit?: number;
            maxDepth?: number;
            offset?: number;
            prefix?: string[];
            suffix?: string[];
        }
        • Optionallimit?: number

          Maximum number of namespaces to return (default is 100).

        • OptionalmaxDepth?: number

          Optional integer specifying the maximum depth of namespaces to return.

        • Optionaloffset?: number

          Number of namespaces to skip before returning results (default is 0).

        • Optionalprefix?: string[]

          Optional list of strings representing the prefix to filter namespaces.

        • Optionalsuffix?: string[]

          Optional list of strings representing the suffix to filter namespaces.

      Returns Promise<ListNamespaceResponse>

      Promise

    • Parameters

      • path: string
      • Optionaloptions: RequestInit & {
            json?: unknown;
            params?: Record<string, unknown>;
            timeoutMs?: null | number;
            withResponse?: boolean;
        }

      Returns [url: URL, init: RequestInit]

    • Store or update an item.

      Parameters

      • namespace: string[]

        A list of strings representing the namespace path.

      • key: string

        The unique identifier for the item within the namespace.

      • value: Record<string, unknown>

        A dictionary containing the item's data.

      • Optionaloptions: { index?: null | false | string[]; ttl?: null | number }
        • Optionalindex?: null | false | string[]

          Controls search indexing - null (use defaults), false (disable), or list of field paths to index.

        • Optionalttl?: null | number

          Optional time-to-live in minutes for the item, or null for no expiration.

      Returns Promise<void>

      Promise

      await client.store.putItem(
      ["documents", "user123"],
      "item456",
      { title: "My Document", content: "Hello World" },
      { ttl: 60 } // expires in 60 minutes
      );
    • Search for items within a namespace prefix.

      Parameters

      • namespacePrefix: string[]

        List of strings representing the namespace prefix.

      • Optionaloptions: {
            filter?: Record<string, unknown>;
            limit?: number;
            offset?: number;
            query?: string;
            refreshTtl?: null | boolean;
        }
        • Optionalfilter?: Record<string, unknown>

          Optional dictionary of key-value pairs to filter results.

        • Optionallimit?: number

          Maximum number of items to return (default is 10).

        • Optionaloffset?: number

          Number of items to skip before returning results (default is 0).

        • Optionalquery?: string

          Optional search query.

        • OptionalrefreshTtl?: null | boolean

          Whether to refresh the TTL on items returned by this search. If null, uses the store's default behavior.

      Returns Promise<SearchItemsResponse>

      Promise

      const results = await client.store.searchItems(
      ["documents"],
      {
      filter: { author: "John Doe" },
      limit: 5,
      refreshTtl: true
      }
      );
      console.log(results);
      // {
      // items: [
      // {
      // namespace: ["documents", "user123"],
      // key: "item789",
      // value: { title: "Another Document", author: "John Doe" },
      // createdAt: "2024-07-30T12:00:00Z",
      // updatedAt: "2024-07-30T12:00:00Z"
      // },
      // // ... additional items ...
      // ]
      // }