Project Files
dist / db.d.ts
export declare const DEFAULT_DB_STORAGE_FILENAME = "kv-store.db";
export declare const MAX_VALUE_LENGTH_CHARS: number;
export declare function getDefaultStoragePath(): string;
export declare class KvDatabase {
private db;
private readonly dbPath;
private readonly dbDir;
private initialized;
constructor(storageFilename?: string);
/** Must be called before any other method. Loads WASM + opens/creates DB. */
init(): Promise<void>;
private setupSchema;
/** Write in-memory DB to disk. Called after every write operation. */
private persist;
/**
* Insert or replace a key-value pair.
* Updates `updated_at` on conflict; preserves `created_at`.
*/
set(key: string, value: string): void;
/**
* Append text to an existing value, or create the key if it does not exist.
* Returns the resulting stored value.
*/
append(key: string, value: string): string;
/**
* Retrieve the value for a key, or null if the key does not exist.
* Returns the raw stored text string.
*/
get(key: string): string | null;
/**
* Retrieve values for multiple keys using a single SQL query.
* Returns only keys that exist and preserves input order, including duplicates.
*/
getMany(keys: string[]): Array<{
key: string;
value: string | null;
}>;
/** Delete a key-value pair. No-op if the key does not exist. */
delete(key: string): void;
/**
* Delete multiple key-value pairs in a single SQL operation.
* No-op for keys that do not exist.
*/
deleteMany(keys: string[]): void;
/**
* Rename a key while preserving its value and created_at timestamp.
* Fails if the source key does not exist or the target key already exists.
*/
rename(oldKey: string, newKey: string): void;
/**
* List all keys in the store, optionally filtering by a match string.
* The match string is used as a SQL LIKE pattern (case-insensitive).
*/
listKeys(match?: string, limit?: number, offset?: number): string[];
/** Count keys in the store, optionally filtering by a case-insensitive substring. */
countKeys(match?: string): number;
close(): void;
}
//# sourceMappingURL=db.d.ts.map