Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Collection

class Collection {
constructor(
name: string,
id: string,
client: ChromaClient,
embeddingFunction: IEmbeddingFunction,
metadata?: CollectionMetadata,
);
private client;
embeddingFunction: IEmbeddingFunction;
id: string;
metadata: CollectionMetadata | undefined;
name: string;
 
add(params: AddRecordsParams): Promise<void>;
count(): Promise<number>;
delete({ ids, where, whereDocument }?: DeleteParams): Promise<void>;
get({ ids, where, limit, offset, include, whereDocument }?: BaseGetParams): Promise<GetResponse>;
modify({ name, metadata }: {
name?: string;
metadata?: CollectionMetadata;
}
): Promise<CollectionParams>;
peek({ limit }?: PeekParams): Promise<MultiGetResponse>;
query({ nResults, where, whereDocument, include, queryTexts, queryEmbeddings }: QueryRecordsParams): Promise<MultiQueryResponse>;
update(params: UpdateRecordsParams): Promise<void>;
upsert(params: UpsertRecordsParams): Promise<void>;
}

§Constructors

§
new Collection(name: string, id: string, client: ChromaClient, embeddingFunction: IEmbeddingFunction, metadata?: CollectionMetadata)
[src]

§Properties

§
client
[src]
§
embeddingFunction: IEmbeddingFunction
[src]
§
id: string
[src]
§
metadata: CollectionMetadata | undefined
[src]
§
name: string
[src]

§Methods

§
add(params: AddRecordsParams): Promise<void>
[src]

Add items to the collection

@param params
  • The parameters for the query.
@return
  • The response from the API. True if successful.
@example
const response = await collection.add({
  ids: ["id1", "id2"],
  embeddings: [[1, 2, 3], [4, 5, 6]],
  metadatas: [{ "key": "value" }, { "key": "value" }],
  documents: ["document1", "document2"]
});
§
count(): Promise<number>
[src]

Count the number of items in the collection

@return
  • The number of items in the collection.
@example
const count = await collection.count();
§
delete({ ids, where, whereDocument }?: DeleteParams): Promise<void>
[src]

Deletes items from the collection.

@param params
  • The parameters for deleting items from the collection.
@return

A promise that resolves to the IDs of the deleted items.

@example
const results = await collection.delete({
  ids: "some_id",
  where: {"name": {"$eq": "John Doe"}},
  whereDocument: {"$contains":"search_string"}
});
§
get({ ids, where, limit, offset, include, whereDocument }?: BaseGetParams): Promise<GetResponse>
[src]

Get items from the collection

@param params
  • The parameters for the query.
@return
  • The response from the server.
@example
const response = await collection.get({
  ids: ["id1", "id2"],
  where: { "key": "value" },
  limit: 10,
  offset: 0,
  include: ["embeddings", "metadatas", "documents"],
  whereDocument: { $contains: "value" },
});
§
modify({ name, metadata }: {
name?: string;
metadata?: CollectionMetadata;
}
): Promise<CollectionParams>
[src]

Modify the collection name or metadata

@param params
  • The parameters for the query.
@return
  • The response from the API.
@example
const response = await client.updateCollection({
  name: "new name",
  metadata: { "key": "value" },
});
§
peek({ limit }?: PeekParams): Promise<MultiGetResponse>
[src]

Peek inside the collection

@param params
  • The parameters for the query.
@return

A promise that resolves to the query results.

@example
const results = await collection.peek({
  limit: 10
});
§
query({ nResults, where, whereDocument, include, queryTexts, queryEmbeddings }: QueryRecordsParams): Promise<MultiQueryResponse>
[src]

Performs a query on the collection using the specified parameters.

@param params
  • The parameters for the query.
@return

A promise that resolves to the query results.

@example
// Query the collection using embeddings
const results = await collection.query({
  queryEmbeddings: [[0.1, 0.2, ...], ...],
  nResults: 10,
  where: {"name": {"$eq": "John Doe"}},
  include: ["metadata", "document"]
});
@example
// Query the collection using query text
const results = await collection.query({
  queryTexts: "some text",
  nResults: 10,
  where: {"name": {"$eq": "John Doe"}},
  include: ["metadata", "document"]
});
§
update(params: UpdateRecordsParams): Promise<void>
[src]

Update items in the collection

@param params
  • The parameters for the query.
@return
@example
const response = await collection.update({
  ids: ["id1", "id2"],
  embeddings: [[1, 2, 3], [4, 5, 6]],
  metadatas: [{ "key": "value" }, { "key": "value" }],
  documents: ["document1", "document2"],
});
§
upsert(params: UpsertRecordsParams): Promise<void>
[src]

Upsert items to the collection

@param params
  • The parameters for the query.
@return
@example
const response = await collection.upsert({
  ids: ["id1", "id2"],
  embeddings: [[1, 2, 3], [4, 5, 6]],
  metadatas: [{ "key": "value" }, { "key": "value" }],
  documents: ["document1", "document2"],
});