Node.js library for pgvector support
Top 73.5% on sourcepulse
This library provides Node.js, Deno, and Bun bindings for the pgvector
PostgreSQL extension, enabling efficient storage and similarity search of vector embeddings. It supports a wide range of popular ORMs and database clients, simplifying integration for developers building AI-powered applications.
How It Works
The library acts as a bridge between JavaScript/TypeScript environments and the pgvector
extension's SQL capabilities. It offers helper functions to register custom vector types with database clients, convert JavaScript arrays to pgvector
's SQL format, and construct SQL queries for common operations like creating tables with vector columns, inserting vectors, and performing nearest neighbor searches using various distance metrics (L2, cosine, inner product). It also facilitates the creation of approximate nearest neighbor (ANN) indexes like HNSW and IVFFlat.
Quick Start & Requirements
npm install pgvector
pgvector
extension installed.pgvector/pg
, pgvector/knex
) and follow the provided examples for enabling extensions, creating tables, inserting data, and querying.Highlighted Details
Maintenance & Community
npm test
.Licensing & Compatibility
Limitations & Caveats
migrate dev
does not support pgvector
indexes directly, requiring manual SQL for index creation.2 weeks ago
1 day