pgvector/pgvector-node
pgvector support for Node.js, Deno, and Bun (and TypeScript)
What it solves
This library enables Node.js, Deno, and Bun applications to work seamlessly with the pgvector PostgreSQL extension. It bridges the gap between JavaScript/TypeScript environments and the database, allowing developers to store, index, and perform similarity searches on vector embeddings directly within their SQL databases.
How it works
It provides helper utilities to register vector types and format data for various database drivers and ORMs. Once integrated, you can use standard database commands to create vector columns, insert embedding arrays, and perform nearest-neighbor queries using operators like <-> (L2 distance), inner product, or cosine distance. It also supports advanced features like sparse vectors and approximate indexing (HNSW or IVFFlat) to optimize search performance.
Who it’s for
It is designed for developers building AI-powered applications—such as those using OpenAI, Cohere, or Transformers.js—who need to store and query vector data within a PostgreSQL database using popular JavaScript tools like Prisma, Drizzle, Sequelize, Knex, or raw SQL drivers.
Highlights
- Broad compatibility with major ORMs including Prisma, Drizzle, TypeORM, MikroORM, Knex, and Objection.js.
- Supports native SQL drivers like node-postgres, Postgres.js, Slonik, pg-promise, deno-postgres, and Bun SQL.
- Simplifies vector operations like L2 distance, inner product, cosine distance, L1 distance, and Jaccard distance.
- Includes support for sparse vectors and approximate index types (HNSW and IVFFlat) for scalable search.
- Provides ready-to-run examples for common use cases like hybrid search, recommendations, and bulk data loading.
Related
- Project
- Project
- Project
- Project
- Project