Zvec Node.js API Reference
    Preparing search index...

    Class ZVecCollection

    Represents a collection in Zvec.

    Index

    Methods

    • Inserts a single document into the collection.

      Parameters

      Returns ZVecStatus

      The status of the operation.

    • Inserts a batch of documents into the collection.

      Parameters

      Returns ZVecStatus[]

      An array of statuses of the operation.

    • Inserts a single document into the collection, or updates it if it already exists based on its ID.

      Parameters

      Returns ZVecStatus

      The status of the operation.

    • Inserts a batch of documents into the collection, or updates them if they already exist based on their ID.

      Parameters

      Returns ZVecStatus[]

      An array of statuses of the operation.

    • Updates a single existing document by ID. Only specified fields and vectors are updated; others remain unchanged.

      Parameters

      • docs: ZVecDocInput

        A single document containing the updated data.

      Returns ZVecStatus

      The status of the operation.

    • Updates multiple existing documents by ID. Only specified fields and vectors are updated; others remain unchanged.

      Parameters

      • docs: ZVecDocInput[]

        An array of documents containing the updated data.

      Returns ZVecStatus[]

      An array of statuses of the operation.

    • Deletes a single document by its ID.

      Parameters

      • ids: string

        A single document ID to delete.

      Returns ZVecStatus

      The status of the operation.

    • Deletes multiple documents by their IDs.

      Parameters

      • ids: string[]

        An array of document IDs to delete.

      Returns ZVecStatus[]

      An array of statuses of the operation.

    • Deletes documents based on a filter expression.

      Parameters

      • filter: string

        A string representing the filter expression.

      Returns ZVecStatus

      The status of the operation.

    • Performs a vector similarity search query.

      Parameters

      Returns ZVecDoc[]

      An array of documents ranked by similarity to the query vector.

    • Fetches documents by their IDs.

      Parameters

      • ids: string | string[]

        A single document ID or an array of document IDs to fetch.

      Returns Record<string, ZVecDoc>

      An object mapping the requested IDs to their corresponding documents. If an ID is not found, it will not be present in the returned object.

    • Optimizes the collection's internal structures for better performance.

      Parameters

      Returns void

      If the operation fails.

    • Closes the collection and releases its resources. After calling this method, the collection object should not be used.

      Returns void

      If the operation fails.

    • Permanently deletes the collection from disk. After calling this method, the collection object should not be used.

      Returns void

      If the operation fails.

    • Adds a new column to the collection.

      Parameters

      • params: {
            fieldSchema: ZVecFieldSchema;
            expression?: string;
            options?: ZVecAddColumnOptions;
        }

        An object containing the parameters for the operation.

        • fieldSchema: ZVecFieldSchema

          The schema definition for the new column.

        • Optionalexpression?: string

          Optional expression to compute values for existing documents.

        • Optionaloptions?: ZVecAddColumnOptions

          Optional parameters for the operation.

      Returns void

      If the operation fails.

    • Permanently deletes a column from the collection. After dropping, the data and schema for this column are removed.

      Parameters

      • fieldName: string

        The name of the column to drop.

      Returns void

      If the operation fails.

    • Alters an existing column in the collection. You can either rename the column or modify its schema.

      Parameters

      • params: {
            columnName: string;
            newColumnName?: string;
            fieldSchema?: ZVecFieldSchema;
            options?: ZVecAlterColumnOptions;
        }

        An object containing the parameters for the operation.

        • columnName: string

          The current name of the column to alter.

        • OptionalnewColumnName?: string

          The new name for the column (mutually exclusive with fieldSchema).

        • OptionalfieldSchema?: ZVecFieldSchema

          The new schema definition for the column (mutually exclusive with newColumnName).

        • Optionaloptions?: ZVecAlterColumnOptions

          Optional parameters for the operation.

      Returns void

      If the operation fails.

    • Creates an index on a specific column in the collection.

      Parameters

      • params: {
            fieldName: string;
            indexParams: ZVecIndexParams;
            indexOptions?: ZVecCreateIndexOptions;
        }

        An object containing the parameters for the operation.

        • fieldName: string

          The name of the column to create the index on.

        • indexParams: ZVecIndexParams

          The configuration parameters defining the index type and properties.

        • OptionalindexOptions?: ZVecCreateIndexOptions

          Optional parameters for the index creation operation.

      Returns void

      If the operation fails.

    • Drops (removes) an existing index from the collection.

      Parameters

      • fieldName: string

        The name of the column whose index should be dropped.

      Returns void

      If the operation fails.

    Properties

    path: string

    Gets the file system path associated with this collection.

    Gets the schema defining the structure of this collection.

    Gets the options used when this collection was opened/created.

    stats: { docCount: number; indexCompleteness: Record<string, number> }

    Gets statistics about this collection.