Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Database

Implementation of NoSQL DB that uses paths and objects.

See DatabaseInterface for docs on public API

Uses a plain object as a buffer and reads/writes to a plain JSON file. A better implementation could be backed by somethig a little nicer and not hold the buffer in memory

Hierarchy

  • Database

Implements

Index

Constructors

constructor

Properties

Private buff

buff: any

Private ctx

ctx: Context

Methods

flush

  • flush(): Promise<void>

Private hasSpace

  • hasSpace(): boolean

init

  • init(): Promise<void>

read

  • read(path: string): Promise<Object>

Private resolve

  • resolve(pathParts: string[], isRead?: boolean, level?: number): any
  • Resolve the object located at path.

    If isRead == true, no new nodes will be created, and the function will return null if a null node is encountered on the path. Else, we create each node on the path.

    Level is used to determine how deep to recurse on path. Callers interested in writing may wish to stop higher up the tree.

    Parameters

    • pathParts: string[]
    • Default value isRead: boolean = true
    • Default value level: number = 0

    Returns any

Private serialize

  • serialize(): Promise<void>
  • Serialize the current buffer into a plain file.

    Change the path by injecting custom Context

    Throws OUT_OF_SPACE

    Returns Promise<void>

toString

  • toString(): string

write

  • write(path: string, toWrite: Object): Promise<void>

Generated using TypeDoc