/** * Embedded Database - FFI Mode * * Direct FFI access to ToonDB native library. * No server required - similar to Python SDK's Database class. */ import { NativeBindings } from './ffi/bindings'; import { EmbeddedTransaction } from './transaction'; export interface EmbeddedDatabaseConfig { walEnabled?: boolean; syncMode?: 'full' | 'normal' | 'off'; memtableSizeBytes?: number; groupCommit?: boolean; indexPolicy?: 'write_optimized' | 'balanced' | 'scan_optimized' | 'append_only'; } /** * Embedded Database using direct FFI * * @example * ```typescript * import { EmbeddedDatabase } from '@sushanth/toondb'; * * const db = await EmbeddedDatabase.open('./mydb'); * await db.put(Buffer.from('key'), Buffer.from('value')); * const value = await db.get(Buffer.from('key')); * await db.close(); * ``` */ export declare class EmbeddedDatabase { private handle; private bindings; private closed; private path; private constructor(); /** * Open a database at the specified path * * @param path - Path to database directory * @param config - Optional configuration * @returns EmbeddedDatabase instance */ static open(path: string, config?: EmbeddedDatabaseConfig): EmbeddedDatabase; /** * Put a key-value pair (auto-transaction) */ put(key: Buffer, value: Buffer): Promise; /** * Get a value by key (auto-transaction) */ get(key: Buffer): Promise; /** * Delete a key (auto-transaction) */ delete(key: Buffer): Promise; /** * Put value at path (auto-transaction) */ putPath(path: string, value: Buffer): Promise; /** * Get value at path (auto-transaction) */ getPath(path: string): Promise; /** * Scan keys with prefix */ scanPrefix(prefix: Buffer): AsyncGenerator<[Buffer, Buffer]>; /** * Begin a transaction */ transaction(): EmbeddedTransaction; /** * Execute operations within a transaction (with auto-commit/abort) */ withTransaction(fn: (txn: EmbeddedTransaction) => Promise): Promise; /** * Force a checkpoint */ checkpoint(): Promise; /** * Get storage statistics */ stats(): Promise<{ memtableSizeBytes: bigint; walSizeBytes: bigint; activeTransactions: number; minActiveSnapshot: bigint; lastCheckpointLsn: bigint; }>; /** * Close the database */ close(): void; private ensureOpen; /** * Get internal handle (for transactions) * @internal */ getHandle(): any; /** * Get bindings instance (for transactions) * @internal */ getBindings(): NativeBindings; } //# sourceMappingURL=database.d.ts.map