Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/db/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export async function cloudflare(config: CloudflareConfig): Promise<SearchProvid
return { count: ids.length }
},

// listIds() is not implemented — Cloudflare Vectorize Workers binding
// does not expose a list/range method (only available via REST API).
// This means remove() with chunking (via createRetriv) is not supported.

async clear() {
throw new Error('[cloudflare] clear() is not supported - use wrangler CLI instead')
},
Expand Down
5 changes: 5 additions & 0 deletions src/db/libsql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ export async function libsql(config: LibsqlConfig): Promise<SearchProvider> {
return { count: ids.length }
},

async listIds() {
const result = await client.execute('SELECT id FROM vectors')
return (result.rows || []).map((row: any) => row.id as string)
},

async clear() {
await client.execute('DELETE FROM vectors')
},
Expand Down
5 changes: 5 additions & 0 deletions src/db/pgvector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export async function pgvector(config: PgvectorConfig): Promise<SearchProvider>
return { count: ids.length }
},

async listIds() {
const result = await pool.query(`SELECT id FROM ${table}`)
return result.rows.map((row: any) => row.id as string)
},

async clear() {
await pool.query(`DELETE FROM ${table}`)
},
Expand Down
5 changes: 5 additions & 0 deletions src/db/sqlite-vec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ export async function sqliteVec(config: SqliteVecConfig): Promise<SearchProvider
}
},

async listIds() {
const rows = db.prepare('SELECT id FROM vector_metadata').all() as { id: string }[]
return rows.map(r => r.id)
},

async clear() {
db.exec('DELETE FROM vectors')
db.exec('DELETE FROM vector_metadata')
Expand Down
11 changes: 11 additions & 0 deletions src/db/upstash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ export async function upstash(config: UpstashConfig): Promise<SearchProvider> {
return { count: ids.length }
},

async listIds() {
const ids: string[] = []
let cursor = '0'
do {
const page = await index.range({ cursor, limit: 1000, includeMetadata: false, includeVectors: false }, { namespace: ns })
for (const v of page.vectors) ids.push(v.id as string)
cursor = page.nextCursor
} while (cursor !== '0')
return ids
},

async clear() {
await index.reset({ namespace: ns })
},
Expand Down
2 changes: 1 addition & 1 deletion src/retriv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export async function createRetriv(options: RetrivOptions): Promise<SearchProvid
if (chunker) {
const lister = drivers.find(d => d.listIds)
if (!lister)
throw new Error('remove() with chunking requires a driver that implements listIds()')
throw new Error('remove() with chunking requires a driver that implements listIds() — cloudflare does not support this')
const allIds = await lister.listIds!()
const idSet = new Set(ids)
removeIds = allIds.filter((id) => {
Expand Down
Loading