Postgres

Configure @vitehub/vector against a pgvector-backed Postgres database.

Use the Postgres provider when you want to keep vector storage inside your own database with pgvector.

Before you start

Install @vitehub/vector and pg:

Terminal
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/vector@main pg

Make sure the target database is reachable from your app and supports the vector extension.

Configure Postgres

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vitehub/vector/nuxt'],
  vector: {
    provider: 'postgres',
    connectionString: process.env.DATABASE_URL,
    schema: 'public',
    tablePrefix: 'vitehub_vector_',
  },
})

If you omit connectionString, ViteHub also checks VECTOR_DATABASE_URL and DATABASE_URL.

Define a vector

server/vectors/docs.ts
export default defineVector({
  dimensions: 1536,
  metric: 'dot-product',
  filterable: ['tenantId', 'kind'],
  providers: {
    postgres: {
      tablePrefix: 'search_',
    },
  },
})

Query the vector

const docs = getVector('docs')

const matches = await docs.query({
  vector: [0.1, 0.2, 0.3],
  topK: 5,
  filter: {
    tenantId: 'acme',
    kind: ['guide', 'api'],
  },
})

Postgres-specific options

OptionUse it for
connectionStringPoint ViteHub at the database that stores your vector tables.
schemaChoose the schema where ViteHub creates vector tables.
tablePrefixPrefix generated table names globally or per vector definition.

What changes on Postgres

ConcernBehavior
Table creationViteHub creates one table per discovered vector name.
IndexingViteHub ensures the vector extension and builds an HNSW index for the selected metric.
FilteringMetadata filters run through JSONB using the portable equality and in subset.
Native handlegetVector(name).native gives you the raw Postgres-backed vector handle.
Choose Postgres when you want vector search close to the rest of your relational data and you are comfortable operating the database yourself.