UNPKG

hnswsqlite

Version:

Vector search with HNSWlib and SQLite in TypeScript.

16 lines (13 loc) 477 B
import { VectorStore } from '../../vectorStore'; import { mkdirSync, existsSync } from 'fs'; import path from 'path'; export function initDatabase(dbPath: string, dim: number): void { // Create directory if it doesn't exist const dir = path.dirname(dbPath); if (dir && !existsSync(dir)) { mkdirSync(dir, { recursive: true }); } // Initialize the store which will create the database and tables const store = new VectorStore(dbPath, dim); store.close(); }