update usage example to resolve tsc error (#867)

## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - update js client usage to align with the type definication

## Test plan
*How are these changes tested?*
- put the usage example into a typescript file, test against the current
version of chromadb client package

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*

This update only change the usage example, there maybe some places in
the documentations also need update for similar reason but it is not
directly related to this pull request.
This commit is contained in:
Beeno Tung
2023-07-24 23:57:50 +08:00
committed by GitHub
parent 3ed229ccb9
commit f645c774ec

View File

@@ -19,14 +19,19 @@ Chroma needs to be running in order for this client to talk to it. Please see th
```js
import { ChromaClient } from "chromadb";
const chroma = new ChromaClient("http://localhost:8000");
const collection = await chroma.createCollection("test-from-js");
const chroma = new ChromaClient({ path: "http://localhost:8000" });
const collection = await chroma.createCollection({ name: "test-from-js" });
for (let i = 0; i < 20; i++) {
await collection.add("test-id-" + i.toString(), [1, 2, 3, 4, 5], {
test: "test",
await collection.add({
ids: ["test-id-" + i.toString()],
embeddings, [1, 2, 3, 4, 5],
documents: ["test"],
});
}
const queryData = await collection.query([1, 2, 3, 4, 5], 5, { test: "test" });
const queryData = await collection.query({
queryEmbeddings: [1, 2, 3, 4, 5],
queryTexts: ["test"],
});
```
## Local development