UNPKG

axiodb

Version:

The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platfor

42 lines (41 loc) 1.62 kB
import { IndexManager } from "./Index.service"; /** * Service for removing documents from indexes * * When a document is deleted, this service removes its reference from all * relevant index entries to prevent stale references and maintain index integrity. * * @example * ```typescript * const deleteIndex = new DeleteIndex('/path/to/collection'); * await deleteIndex.RemoveFromIndex('doc123', { email: 'test@example.com' }); * ``` */ export default class DeleteIndex extends IndexManager { private indexCache; constructor(path: string); /** * Removes a document from all matching indexes * * For each indexed field present in the document: * 1. Loads the index data from cache (or disk if not cached) * 2. Removes the document filename from indexEntries[fieldValue] * 3. Deletes the entry key if array becomes empty * 4. Updates both memory cache and disk atomically * * @param documentId - The document ID to remove (without file extension) * @param document - The document data containing indexed field values * @returns True if at least one index was updated, false otherwise */ RemoveFromIndex(documentId: string, document: any): Promise<boolean>; /** * Removes multiple documents from all matching indexes (batch operation) * * @param documents - Array of { documentId, document } pairs to remove * @returns True if at least one index was updated, false otherwise */ RemoveMultipleFromIndex(documents: Array<{ documentId: string; document: any; }>): Promise<boolean>; }