Class DB

Hierarchy

  • CreateDestroyStartStop
    • DB

Constructors

  • Parameters

    • __namedParameters: {
          dbPath: string;
          deadlock: boolean;
          fs: FileSystem;
          logger: Logger;
      }
      • dbPath: string
      • deadlock: boolean
      • fs: FileSystem
      • logger: Logger

    Returns DB

Properties

[initLock]: RWLockWriter
_iteratorRefs: Set<DBIterator<any, any>> = ...

References to iterators

_lockBox: LockBox<RWLockWriter> = ...
_locksPending?: Map<string, {
    count: number;
}>

Type declaration

  • count: number
_transactionRefs: Set<DBTransaction> = ...

References to transactions

crypto?: {
    key: Buffer;
    ops: Crypto;
}

Type declaration

dbPath: string
logger: Logger
workerManager?: DBWorkerManagerInterface

Accessors

  • get [destroyed](): boolean
  • Returns boolean

  • get [eventHandled](): WeakSet<Event>
  • Returns WeakSet<Event>

  • get [eventHandlers](): WeakMap<EventListenerOrEventListenerObject, EventListener>
  • Returns WeakMap<EventListenerOrEventListenerObject, EventListener>

  • get [eventTarget](): EventTarget
  • Returns EventTarget

  • get [running](): boolean
  • Returns boolean

  • get [status](): Status
  • Returns Status

  • get lockBox(): Readonly<LockBox<RWLockWriter>>
  • Returns Readonly<LockBox<RWLockWriter>>

Methods

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Batches operations together atomically

    Parameters

    • ops: readonly DBOp[]
    • sync: boolean = false

    Returns Promise<void>

  • Returns Promise<void>

  • Clear all key values for a specific level This is not atomic, it will iterate over a snapshot of the DB

    Parameters

    • levelPath: readonly (string | Buffer)[] = []
    • options: DBClearOptions = {}

    Returns Promise<void>

  • Parameters

    • levelPath: readonly (string | Buffer)[] = []
    • options: DBCountOptions = {}

    Returns Promise<number>

  • Deletes a key from the DB

    Parameters

    • keyPath: string | Buffer | readonly (string | Buffer)[]
    • sync: boolean = false

    Returns Promise<void>

  • Type Parameters

    • T

    Parameters

    • cipherTextBuf: Buffer
    • raw: false

    Returns Promise<T>

  • Parameters

    • cipherTextBuf: Buffer
    • raw: true

    Returns Promise<Buffer>

  • Returns Promise<void>

  • Parameters

    • event: Event

    Returns boolean

  • Dump from DB This will show entries from all levels It is intended for diagnostics Use console.dir instead of console.log to debug the result Set root to true if you want to dump from root levels

    Type Parameters

    • V

    Parameters

    • Optional levelPath: readonly (string | Buffer)[]
    • Optional raw: false
    • Optional root: boolean

    Returns Promise<[readonly (string | Buffer)[], V][]>

  • Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • raw: true
    • Optional root: boolean

    Returns Promise<[readonly (string | Buffer)[], Buffer][]>

  • Gets a value from the DB Use raw to return the raw decrypted buffer

    Type Parameters

    • T

    Parameters

    • keyPath: string | Buffer | readonly (string | Buffer)[]
    • Optional raw: false

    Returns Promise<undefined | T>

  • Parameters

    • keyPath: string | Buffer | readonly (string | Buffer)[]
    • raw: true

    Returns Promise<undefined | Buffer>

  • Public iterator that works from the data level If keys and values are both false, this iterator will not run at all You must have at least one of them being true or undefined

    Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • options: DBIteratorOptions & {
          keys: false;
          values: false;
      }

    Returns DBIterator<undefined, undefined>

  • Type Parameters

    • V

    Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • options: DBIteratorOptions & {
          keys: false;
          valueAsBuffer: false;
      }

    Returns DBIterator<undefined, V>

  • Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • options: DBIteratorOptions & {
          keys: false;
      }

    Returns DBIterator<undefined, Buffer>

  • Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • options: DBIteratorOptions & {
          values: false;
      }

    Returns DBIterator<readonly (string | Buffer)[], undefined>

  • Type Parameters

    • V

    Parameters

    • levelPath: undefined | readonly (string | Buffer)[]
    • options: DBIteratorOptions & {
          valueAsBuffer: false;
      }

    Returns DBIterator<readonly (string | Buffer)[], V>

  • Parameters

    • Optional levelPath: readonly (string | Buffer)[]
    • Optional options: DBIteratorOptions

    Returns DBIterator<readonly (string | Buffer)[], Buffer>

  • Put a key and value into the DB Use raw to put raw encrypted buffer

    Parameters

    • keyPath: string | Buffer | readonly (string | Buffer)[]
    • value: any
    • Optional raw: false
    • Optional sync: boolean

    Returns Promise<void>

  • Parameters

    • keyPath: string | Buffer | readonly (string | Buffer)[]
    • value: Buffer
    • raw: true
    • Optional sync: boolean

    Returns Promise<void>

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Parameters

    • value: any
    • raw: false

    Returns Promise<Buffer>

  • Parameters

    • value: Buffer
    • raw: true

    Returns Promise<Buffer>

  • Returns Promise<void>

  • Parameters

    • __namedParameters: {
          crypto?: {
              key: Buffer;
              ops: Crypto;
          };
          fresh?: boolean;
      } & DBOptions = {}

    Returns Promise<void>

  • Returns Promise<void>

  • Returns void

  • Type Parameters

    • T

    Parameters

    • f: ((tran) => Promise<T>)
        • (tran): Promise<T>
        • Parameters

          Returns Promise<T>

    Returns Promise<T>

  • Type Parameters

    • T

    • TReturn

    • TNext

    Parameters

    • g: ((tran) => AsyncGenerator<T, TReturn, TNext>)
        • (tran): AsyncGenerator<T, TReturn, TNext>
        • Parameters

          Returns AsyncGenerator<T, TReturn, TNext>

    Returns AsyncGenerator<T, TReturn, TNext>

  • Parameters

    • __namedParameters: {
          crypto?: {
              key: Buffer;
              ops: Crypto;
          };
          dbPath: string;
          deadlock?: boolean;
          fresh?: boolean;
          fs?: FileSystem;
          logger?: Logger;
      } & DBOptions

    Returns Promise<DB>

Generated using TypeDoc