Class: ChromaClient
Hierarchy
ChromaClient
Constructors
constructor
• new ChromaClient(params?
)
Creates a new ChromaClient instance.
Example
const client = new ChromaClient({
path: "http://localhost:8000"
});
Parameters
Name | Type | Description |
---|---|---|
params | ChromaClientParams | The parameters for creating a new client |
Properties
_adminClient
• Private
Optional
_adminClient: AdminClient
apiAdapter
• Private
apiAdapter: undefined
| ClientAuthProtocolAdapter
<any
>
database
• Private
database: string
= DEFAULT_DATABASE
tenant
• Private
tenant: string
= DEFAULT_TENANT
Methods
countCollections
▸ countCollections(): Promise
<number
>
Counts all collections.
Throws
If there is an issue counting the collections.
Example
const collections = await client.countCollections();
Returns
Promise
<number
>
A promise that resolves to the number of collections.
createCollection
▸ createCollection(params
): Promise
<Collection
>
Creates a new collection with the specified properties.
Throws
If there is an issue creating the collection.
Example
const collection = await client.createCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Parameters
Name | Type | Description |
---|---|---|
params | CreateCollectionParams | The parameters for creating a new collection. |
Returns
Promise
<Collection
>
A promise that resolves to the created collection.
deleteCollection
▸ deleteCollection(params
): Promise
<void
>
Deletes a collection with the specified name.
Throws
If there is an issue deleting the collection.
Example
await client.deleteCollection({
name: "my_collection"
});
Parameters
Name | Type | Description |
---|---|---|
params | DeleteCollectionParams | The parameters for deleting a collection. |
Returns
Promise
<void
>
A promise that resolves when the collection is deleted.
getCollection
▸ getCollection(params
): Promise
<Collection
>
Gets a collection with the specified name.
Throws
If there is an issue getting the collection.
Example
const collection = await client.getCollection({
name: "my_collection"
});
Parameters
Name | Type | Description |
---|---|---|
params | GetCollectionParams | The parameters for getting a collection. |
Returns
Promise
<Collection
>
A promise that resolves to the collection.
getOrCreateCollection
▸ getOrCreateCollection(params
): Promise
<Collection
>
Gets or creates a collection with the specified properties.
Throws
If there is an issue getting or creating the collection.
Example
const collection = await client.getOrCreateCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Parameters
Name | Type | Description |
---|---|---|
params | CreateCollectionParams | The parameters for creating a new collection. |
Returns
Promise
<Collection
>
A promise that resolves to the got or created collection.
heartbeat
▸ heartbeat(): Promise
<number
>
Returns a heartbeat from the Chroma API.
Example
const heartbeat = await client.heartbeat();
Returns
Promise
<number
>
A promise that resolves to the heartbeat from the Chroma API.
listCollections
▸ listCollections(«destructured»?
): Promise
<CollectionType
[]>
Lists all collections.
Throws
If there is an issue listing the collections.
Example
const collections = await client.listCollections({
limit: 10,
offset: 0,
});
Parameters
Name | Type |
---|---|
«destructured» | ListCollectionsParams |
Returns
Promise
<CollectionType
[]>
A promise that resolves to a list of collection names.
reset
▸ reset(): Promise
<boolean
>
Resets the state of the object by making an API call to the reset endpoint.
Throws
If there is an issue resetting the state.
Example
await client.reset();
Returns
Promise
<boolean
>
A promise that resolves when the reset operation is complete.
version
▸ version(): Promise
<string
>
Returns the version of the Chroma API.
Example
const version = await client.version();
Returns
Promise
<string
>
A promise that resolves to the version of the Chroma API.