UNPKG

@onurege3467/zerohelper

Version:

ZeroHelper is a versatile high-performance utility library and database framework for Node.js, fully written in TypeScript.

76 lines (75 loc) 2.63 kB
import { IDatabase } from './IDatabase'; import { ZPackConfig } from './types'; /** * ZPackDatabase: Low-level Binary Storage */ export declare class ZPackDatabase { filePath: string; private fd; private fileSize; private index; private deleted; private version; private _nextId; private _writeQueue; private _closed; private _autoFlush; private _contentEnd; private _compression; constructor(filePath: string, options?: { autoFlush?: boolean; compression?: boolean; }); open(): Promise<void>; close(): Promise<void>; vacuum(): Promise<void>; insert(document: Record<string, any>, docId?: number): Promise<number>; insertBatch(documents: Record<string, any>[]): Promise<number[]>; delete(docId: number): Promise<void>; get(docId: number): Promise<Record<string, any> | null>; keys(): number[]; private _ensureOpen; private _enqueue; private _internalWriteFooter; private _writeFooter; private _encodeDocument; private _decodeDocument; private _encodeTombstone; private _peekDocMeta; private _tryLoadIndexFromFooter; private _scanAndRebuildIndex; } /** * ZPackAdapter: IDatabase Implementation */ export declare class ZPackAdapter extends IDatabase { private db; private initPromise; private tableMaxId; private keyIndex; private rowCache; private secondary; private indexedFields; private _isClosing; private _executing; constructor(config: ZPackConfig); private _init; private _execute; private _rawSelect; ensureTable(table: string): Promise<void>; private _updateSecondaryIndex; private _coerce; private _matches; select<T = any>(table: string, where?: Record<string, any> | null): Promise<T[]>; selectOne<T = any>(table: string, where?: Record<string, any> | null): Promise<T | null>; insert(table: string, data: Record<string, any>): Promise<number>; update(table: string, data: Record<string, any>, where: Record<string, any>): Promise<number>; delete(table: string, where: Record<string, any>): Promise<number>; set(table: string, data: Record<string, any>, where: Record<string, any>): Promise<any>; bulkInsert(table: string, dataArray: Record<string, any>[]): Promise<number>; increment(table: string, incs: Record<string, number>, where?: Record<string, any>): Promise<number>; decrement(table: string, decs: Record<string, number>, where?: Record<string, any>): Promise<number>; vacuum(): Promise<void>; close(): Promise<void>; } export default ZPackAdapter;