ChromaClient
§Constructors
Creates a new ChromaClient instance.
- The parameters for creating a new client
const client = new ChromaClient({
path: "http://localhost:8000"
});
§Properties
§Methods
Counts all collections.
A promise that resolves to the number of collections.
const collections = await client.countCollections();
Creates a new collection with the specified properties.
- The parameters for creating a new collection.
- The name of the collection.
A promise that resolves to the created collection.
const collection = await client.createCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Deletes a collection with the specified name.
- The parameters for deleting a collection.
- The name of the collection.
A promise that resolves when the collection is deleted.
await client.deleteCollection({
name: "my_collection"
});
Gets a collection with the specified name.
- The parameters for getting a collection.
- The name of the collection.
A promise that resolves to the collection.
const collection = await client.getCollection({
name: "my_collection"
});
Gets or creates a collection with the specified properties.
- The parameters for creating a new collection.
- The name of the collection.
A promise that resolves to the got or created collection.
const collection = await client.getOrCreateCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Tries to set the tenant and database for the client.
A promise that resolves when the tenant/database is resolved.
Returns a heartbeat from the Chroma API.
A promise that resolves to the heartbeat from the Chroma API.
const heartbeat = await client.heartbeat();
Get all collection names.
A promise that resolves to a list of collection names.
const collections = await client.listCollections({
limit: 10,
offset: 0,
});
List collection names, IDs, and metadata.
const collections = await client.listCollectionsAndMetadata({
limit: 10,
offset: 0,
});