Back to Mastra

Vectors | v1 Migration Guide

docs/src/content/en/guides/migrations/upgrade-to-v1/vectors.mdx

2025-12-182.6 KB
Original Source

Vectors

Vector store constructors now require an id property, and vector store methods have been renamed to follow consistent naming conventions.

Changed

Required id property for vector store instances

Vector store instances now require an id property. This unique identifier is used for tracking and managing vector store instances within Mastra. The id should be a descriptive, unique string for each vector store in your application.

To migrate, add an id field to your vector store constructor.

diff
  const vectorStore = new PgVector({
+   id: 'main-vector-store',
    connectionString: process.env.POSTGRES_CONNECTION_STRING,
  });

  const chromaStore = new ChromaVector({
+   id: 'chroma-embeddings',
    url: process.env.CHROMA_URL,
  });

  const pineconeStore = new PineconeVector({
+   id: 'pinecone-production',
    apiKey: process.env.PINECONE_API_KEY,
  });

getVectors to listVectors

The getVectors() method has been renamed to listVectors(). This change aligns with the naming convention used across the API where plural getter methods use the list prefix.

To migrate, replace all calls to getVectors() with listVectors().

diff
  const vectorStore = new VectorStore({ ... });

- const vectors = await vectorStore.getVectors({ ... });
+ const vectors = await vectorStore.listVectors({ ... });

LibSQLVector: connectionUrl to url

The connectionUrl parameter has been renamed to url to align with the @libsql/client API and match LibSQLStorage.

diff
  const vectorStore = new LibSQLVector({
    id: 'my-vector',
-   connectionUrl: 'file:./db.sqlite',
+   url: 'file:./db.sqlite',
  });

OpenSearchVector: url to node

The url parameter has been renamed to node to match the OpenSearch ClientOptions API. The constructor now accepts all OpenSearch client options including authentication, SSL, and compression.

diff
  const vectorStore = new OpenSearchVector({
    id: 'my-vector',
-   url: 'http://localhost:9200',
+   node: 'http://localhost:9200',
  });

PineconeVector: environment removed

The environment parameter has been removed. Use controllerHostUrl instead if you need to specify a custom controller host. The constructor now accepts all Pinecone configuration options.

diff
  const vectorStore = new PineconeVector({
    id: 'my-vector',
    apiKey: process.env.PINECONE_API_KEY,
-   environment: process.env.PINECONE_ENVIRONMENT,
  });

If you need a custom controller host:

ts
const vectorStore = new PineconeVector({
  id: 'my-vector',
  apiKey: process.env.PINECONE_API_KEY,
  controllerHostUrl: 'https://api.pinecone.io',
})