@rtorcato/cf-common
Interfaces
TypedMatches
Defined in: index.ts:12
Type Parameters
M
M extends VectorMetadata
Properties
matches
matches:
TypedMatch<M>[]
Defined in: index.ts:13
count
count:
number
Defined in: index.ts:14
VectorStore
Defined in: index.ts:18
A typed store over one Vectorize index.
Type Parameters
M
M extends VectorMetadata
Methods
upsert()
upsert(
vectors):Promise<string[]>
Defined in: index.ts:24
Upsert in chunks of 1000 (the Workers binding limit). Returns each chunk's mutationId, in order.
Chunks are sent in order and sending stops at the first failure, so earlier chunks stay upserted.
Throws VECTORIZE_FAILED.
Parameters
vectors
TypedVector<M>[]
Returns
Promise<string[]>
query()
query(
vector,options?):Promise<TypedMatches<M>>
Defined in: index.ts:25
Parameters
vector
VectorFloatArray | number[]
options?
VectorizeQueryOptions
Returns
Promise<TypedMatches<M>>
queryById()
queryById(
id,options?):Promise<TypedMatches<M>>
Defined in: index.ts:29
Parameters
id
string
options?
VectorizeQueryOptions
Returns
Promise<TypedMatches<M>>
getByIds()
getByIds(
ids):Promise<TypedVector<M>[]>
Defined in: index.ts:30
Parameters
ids
string[]
Returns
Promise<TypedVector<M>[]>
deleteByIds()
deleteByIds(
ids):Promise<string>
Defined in: index.ts:32
Returns the mutationId.
Parameters
ids
string[]
Returns
Promise<string>
Type Aliases
VectorMetadata
VectorMetadata =
Record<string,VectorizeVectorMetadata>
Defined in: index.ts:4
Metadata shape for one index. Values follow Vectorize's rules (string | number | boolean | string[]).
TypedVector
TypedVector<
M> =Omit<VectorizeVector,"metadata"> &object
Defined in: index.ts:6
Type Parameters
M
M extends VectorMetadata
Type Declaration
metadata?
optionalmetadata?:M
TypedMatch
TypedMatch<
M> =Omit<VectorizeMatch,"metadata"> &object
Defined in: index.ts:9
Type Parameters
M
M extends VectorMetadata
Type Declaration
metadata?
optionalmetadata?:M
Functions
createVectorStore()
createVectorStore<
M>(index):VectorStore<M>
Defined in: index.ts:49
Wrap a Vectorize index with typed metadata, chunked upserts, and failures
surfaced as a CloudflareError. The M metadata type is asserted by
the caller, as with createKvStore<T>. Nothing is validated at runtime.
Example
const docs = createVectorStore<{ url: string; title: string }>(getBinding<Vectorize>(env, 'DOCS'))
await docs.upsert([{ id: 'a', values, metadata: { url, title } }])
const { matches } = await docs.query(values, { topK: 5, returnMetadata: 'all' })
matches[0]?.metadata?.title // string | undefined
Type Parameters
M
M extends VectorMetadata = VectorMetadata
Parameters
index
Vectorize
Returns
VectorStore<M>