Insert a vector into a DiskANN index
For indexes with metadata columns, use raw SQL instead to specify column names:
Database instance (supports node:sqlite, better-sqlite3, @photostructure/sqlite)
Name of the DiskANN virtual table
Unique row identifier for this vector
Vector as Float32Array or number[] (must match index dimension)
// Basic insert (no metadata)const vec = new Float32Array([0.1, 0.2, 0.3]);insertVector(db, "embeddings", 1, vec);// With metadata - use raw SQL to specify column namesdb.prepare("INSERT INTO photos(rowid, vector, category, year) VALUES (?, ?, ?, ?)") .run(1, vec, 'landscape', 2024); Copy
// Basic insert (no metadata)const vec = new Float32Array([0.1, 0.2, 0.3]);insertVector(db, "embeddings", 1, vec);// With metadata - use raw SQL to specify column namesdb.prepare("INSERT INTO photos(rowid, vector, category, year) VALUES (?, ?, ?, ?)") .run(1, vec, 'landscape', 2024);
Insert a vector into a DiskANN index
For indexes with metadata columns, use raw SQL instead to specify column names: