Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BaseDB

Default structure of the BaseDB. All the database are in this structure and must be.

Hierarchy

  • EventEmitter
    • BaseDB

Implemented by

Index

Constructors

constructor

  • new BaseDB(options?: EventEmitterOptions): BaseDB
  • Parameters

    • Optional options: EventEmitterOptions

    Returns BaseDB

Properties

connected

connected: boolean

Shows if the database is connected

Readonly deserializer

deserializer: (input: string) => any

Deserializer used to deserialize the data

Type declaration

    • (input: string): any
    • Parameters

      • input: string

      Returns any

Readonly name

name: string

Name of the database

Readonly serializer

serializer: (input: any) => string

Serializer used to serialize the data

Type declaration

    • (input: any): string
    • Parameters

      • input: any

      Returns string

Readonly type

type: string

Type of the database

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: unique symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

add

  • Adds the value for the specified key

    example
    await database.add("somekey", 20);
    await database.add(["somekey", "hello.world"], 20); // with Dot notations
    await database.add("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be added

    • value: any

      Value to be added

    Returns Promise<Pair>

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

all

  • all(): Promise<Pair[]>

connect

  • connect(): Promise<void>
  • Connects to the database and perform inital tasks

    example
    await database.connect();

    Returns Promise<void>

delete

  • delete(key: string): Promise<number>
  • Deletes a data pair from the table

    example
    await database.delete();

    Parameters

    • key: string

      Key to be deleted

    Returns Promise<number>

disconnect

  • disconnect(): Promise<void>
  • Disconnects from the database

    example
    await database.disconnect();

    Returns Promise<void>

divide

  • Divides the value for the specified key

    example
    await database.divide("somekey", 20);
    await database.divide(["somekey", "hello.world"], 20); // with Dot notations
    await database.divide("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be divided

    • value: any

      Value to be divided

    Returns Promise<Pair>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

empty

  • empty(): void

entries

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

exponent

  • Raises the value according to the value for the specified key

    example
    await database.exponent("somekey", 20);
    await database.exponent(["somekey", "hello.world"], 20); // with Dot notations
    await database.exponent("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be raised

    • value: any

      Power

    Returns Promise<Pair>

get

  • Sets a value for the specified key

    example
    await database.set("somekey", { hello: { world: true } });
    await database.get(["somekey", "hello.world"]); // with Dot notations
    await database.get("somekey.hello.world"); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be got

    Returns Promise<Pair>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

math

  • Does math for the specified key

    example
    await database.math("somekey", "+", "hello");
    await database.math(["somekey", "hello.world"], "add", 20); // with Dot notations
    await database.math("somekey.hello.world", "addition", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be set

    • operator: Operators

      Math Operator to use used. Refer all operators here: Operators

    • value: any

      Value

    Returns Promise<Pair>

modulo

  • Modulo(s) the value for the specified key

    example
    await database.modulo("somekey", 20);
    await database.modulo(["somekey", "hello.world"], 20); // with Dot notations
    await database.modulo("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be modulo(ed)

    • value: any

      Value to be modulo(ed)

    Returns Promise<Pair>

multiply

  • Multiplies the value for the specified key

    example
    await database.multiply("somekey", 20);
    await database.multiply(["somekey", "hello.world"], 20); // with Dot notations
    await database.multiply("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be multiplied

    • value: any

      Value to be multiplied

    Returns Promise<Pair>

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string, listener: (...args: any[]) => void): this
  • on(event: "connect" | "disconnect", listener: () => void): this
  • on(event: "valueSet" | "valueGet" | "valueUpdate", listener: (pair: Pair) => void): this
  • on(event: "valueDelete", listener: (key: string, deletedCount: number) => void): this
  • on(event: "valueFetch", listener: (pairs: Pair[]) => void): this
  • on(event: "truncate", listener: (deletedCount: number) => void): this
  • Parameters

    • event: string
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

  • Emitted on connect or disconnected

    Parameters

    • event: "connect" | "disconnect"
    • listener: () => void
        • (): void
        • Returns void

    Returns this

  • Emitted when a value is set, retrieved or updated

    Parameters

    • event: "valueSet" | "valueGet" | "valueUpdate"
    • listener: (pair: Pair) => void
        • (pair: Pair): void
        • Parameters

          Returns void

    Returns this

  • Emitted when a value is updated

    Parameters

    • event: "valueDelete"
    • listener: (key: string, deletedCount: number) => void
        • (key: string, deletedCount: number): void
        • Parameters

          • key: string
          • deletedCount: number

          Returns void

    Returns this

  • Emitted when values are fetched

    Parameters

    • event: "valueFetch"
    • listener: (pairs: Pair[]) => void
        • (pairs: Pair[]): void
        • Parameters

          Returns void

    Returns this

  • Emitted when all values are deleted

    Parameters

    • event: "truncate"
    • listener: (deletedCount: number) => void
        • (deletedCount: number): void
        • Parameters

          • deletedCount: number

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

pull

  • Pulles a value into the array of the specified key

    example
    await database.pull("somekey", "hello");
    await database.pull(["somekey", "hello.world"], "hello"); // with Dot notations
    await database.pull("somekey.hello.world", "hello"); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be set

    • value: any

      Value to be set

    Returns Promise<Pair>

push

  • Pushes a value into the array of the specified key

    example
    await database.push("somekey", "hello");
    await database.push(["somekey", "hello.world"], "hello"); // with Dot notations
    await database.push("somekey.hello.world", "hello"); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be set

    • value: any

      Value to be set

    Returns Promise<Pair>

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

set

  • Sets a value for the specified key

    example
    await database.set("somekey", { hello: { world: true } });
    await database.set(["somekey", "hello.world"], false); // with Dot notations
    await database.set("somekey.hello.world", false); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be set

    • value: any

      Value to be set

    Returns Promise<Pair>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

subtract

  • Subtracts the value for the specified key

    example
    await database.subtract("somekey", 20);
    await database.subtract(["somekey", "hello.world"], 20); // with Dot notations
    await database.subtract("somekey.hello.world", 20); // with Dot notations

    Parameters

    • key: KeyParams

      Key for which the data should be subtracted

    • value: any

      Value to be subtracted

    Returns Promise<Pair>

truncate

  • truncate(): Promise<number>
  • Truncates all the data from the table

    example
    await database.truncate();

    Returns Promise<number>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc