pgvector/pgvector-node
pgvector support for Node.js, Deno, and Bun (and TypeScript)
What it solves
pgvector-node provides a standardized way to use the pgvector PostgreSQL extension for vector similarity search in JavaScript and TypeScript environments. It bridges the gap between the database's vector types and various popular Node.js, Deno, and Bun runtimes, allowing developers to store and query embeddings without writing raw SQL for every operation.
How it works
The library acts as a compatibility layer for a wide array of database clients and ORMs. It provides utility functions (like toSql) to format JavaScript arrays into a format the database understands and integrates directly into the schema definitions and query builders of supported libraries. It also supports specialized vector types, including sparse vectors, and provides helper methods for calculating distances (such as L2, cosine, and inner product).
Who it’s for
Backend developers using PostgreSQL as a vector database for AI applications (such as RAG or recommendation systems) who are working with Node.js, Deno, or Bun and using any of the supported ORMs or query builders.
Highlights
- Broad Ecosystem Support: Compatible with a massive list of libraries including Prisma, Sequelize, TypeORM, Drizzle ORM, Knex.js, and Kysely.
- Runtime Flexibility: Works across Node.js, Deno, and Bun.
- Distance Metrics: Built-in support for L2 distance, cosine distance, inner product, Hamming distance, and Jaccard distance.
- Sparse Vector Support: Includes a
SparseVectorclass for handling high-dimensional vectors with many zeros. - Indexing Helpers: Simplifies the creation of HNSW and IVFFlat indexes for approximate nearest neighbor search.
Related
- Project
- Project
- Project
- Project
- Project