Skip to main content

Classes

Client

Client for interacting with the TopK API. For available regions see https://docs.topk.io/regions Constructors Constructor
Creates a new TopK client with the provided configuration. Parameters Returns Client Methods
collection()
Returns a client for interacting with a specific collection. Optionally, pass partition name to scope data operations to that partition. Parameters Returns CollectionClient
collections()
Returns a client for managing collections. This method provides access to collection management operations like creating, listing, and deleting collections. Returns CollectionsClient

CollectionClient

Internal Client for interacting with a specific collection. This client provides methods to perform operations on a specific collection, including querying, upserting, and deleting documents. Methods
count()
Counts the number of documents in the collection. Parameters Returns Promise<number>
delete()
Deletes documents from the collection by their IDs or using a filter expression. Example: Delete documents by their IDs:
Delete documents by a filter expression:
Parameters Returns Promise<string>
deletePartition()
Delete a partition and all documents within it. Parameters Returns Promise<void>
get()
Retrieves documents by their IDs. Parameters Returns Promise<Record<string, Record<string, any>>>
listPartitions()
List partitions in the collection as an async iterator. Parameters Returns PartitionListStream
query()
Executes a query against the collection. Parameters Returns Promise<Record<string, any>[]>
update()
Updates documents in the collection. Existing documents will be merged with the provided fields. Missing documents will be ignored. Parameters Returns Promise<string> The LSN at which the update was applied. If no updates were applied, this will be empty.
upsert()
Inserts or updates documents in the collection. Parameters Returns Promise<string>

CollectionsClient

Internal Client for managing collections. This client provides methods to create, list, get, and delete collections. Methods
create()
Creates a new collection with the specified schema. Parameters Returns Promise<Collection>
delete()
Deletes a collection and all its data.
This operation is irreversible and will permanently delete all data in the collection.
Parameters Returns Promise<void>
get()
Retrieves information about a specific collection. Parameters Returns Promise<Collection>
list()
Lists all collections in the current project. Returns Promise<Collection[]>

PartitionListStream

Iterator for partition list responses. This type implements JavaScript’s async iterable protocol. It can be used with for await...of loops. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols Constructors Constructor
Returns PartitionListStream Methods
[asyncIterator]()
Returns AsyncGenerator<Partition, void, undefined>
next()
Returns the next partition in the stream. Returns Promise<Partition>

Interfaces

BackoffConfig

Configuration for exponential backoff between retry attempts. This struct controls how the delay between retry attempts increases over time. All fields are optional and will use sensible defaults if not provided. Properties

ClientConfig

Configuration for the TopK client. This struct contains all the necessary configuration options to connect to the TopK API. The api_key and region are required, while other options have sensible defaults. Properties

Collection

Represents a collection in the TopK service. A collection is a container for documents with a defined schema. This struct contains metadata about the collection including its name, organization, project, schema, and region. Properties

CollectionFieldSpec

Represents a field specification within a collection schema. This struct defines the properties of a field in a collection, including its data type, whether it’s required, and any index configuration. Properties

Partition

A partition within a collection. Properties

QueryOptions

Options for query operations. These options control the behavior of query operations, including consistency guarantees and sequence number constraints. Properties

RetryConfig

Configuration for retry behavior when requests fail. This struct allows you to customize how the client handles retries for failed requests. All fields are optional and will use sensible defaults if not provided. Properties

Namespaces

Type Aliases

ConsistencyLevel

Consistency levels for query operations.
  • Indexed: Query returns results as soon as they are indexed (faster, eventual consistency)
  • Strong: Query waits for all replicas to be consistent (slower, strong consistency)

SchemaFieldSpec