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

48 lines (47 loc) 1.95 kB
import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface"; import { WALEntry } from "../../config/Interfaces/Transaction/transaction.interface"; export default class WriteAheadLog { private readonly walPath; private readonly transactionDir; private readonly FileManager; private readonly FolderManager; private readonly Converter; private readonly ResponseHelper; private readonly isEncrypted; private readonly cryptoInstance?; private readonly collectionPath; private pendingEntries; private batchSize; private flushTimeout; private readonly flushDelayMs; constructor(collectionPath: string, transactionId: string, isEncrypted?: boolean, encryptionKey?: string); createWAL(): Promise<SuccessInterface | ErrorInterface>; /** * Appends a single log entry. For better performance, use appendLogBatch. */ appendLog(entry: WALEntry): Promise<SuccessInterface | ErrorInterface>; /** * Appends multiple log entries in a single disk write operation. * Much more efficient than calling appendLog multiple times. * * @param entries - Array of WAL entries to write * @returns Success/Error result */ appendLogBatch(entries: WALEntry[]): Promise<SuccessInterface | ErrorInterface>; /** * Queues an entry for batched write. Flushes automatically when batch is full * or after a short delay. * * @param entry - WAL entry to queue */ queueEntry(entry: WALEntry): void; /** * Flushes all pending entries to disk immediately. */ flushPendingEntries(): Promise<SuccessInterface | ErrorInterface>; getLogEntries(): Promise<WALEntry[]>; deleteWAL(): Promise<SuccessInterface | ErrorInterface>; redo(): Promise<SuccessInterface | ErrorInterface>; undo(): Promise<SuccessInterface | ErrorInterface>; private calculateChecksum; }