import { Client } from 'cyborgdb';
const client = new Client({ baseUrl: 'http://localhost:8000', apiKey: 'your-api-key' });
// Load an existing index
const indexKey = new Uint8Array(Buffer.from('your-stored-hex-key', 'hex'));
const index = await client.loadIndex({ indexName: 'my-vector-index', indexKey });
try {
// List all vector IDs in the index
const result = await index.listIds();
console.log('Total items in index:', result.count);
console.log('Item IDs:', result.ids);
// Output: { count: 3, ids: ["doc1", "doc2", "doc3"] }
// Check if a specific ID exists
if (result.ids.includes('doc1')) {
console.log('✓ Item doc1 exists in index');
}
// Use for inventory management
if (result.count === 0) {
console.log('Index is empty');
} else {
console.log(`Index contains ${result.count} items`);
// Process all IDs
for (const id of result.ids) {
console.log(`Processing item: ${id}`);
}
}
} catch (error) {
console.error('Failed to list IDs:', error.message);
}