Class Megdb<V>

Type Parameters

Hierarchy

  • Megdb

Constructors

Properties

cache: Record<string, any>
data: Record<string, any>
driver: JSONDriver<DatabaseMap> | BSONDriver<DatabaseMap> | BINDriver<DatabaseMap>
garbageCollection: undefined | GarbageCollectionOptions

Methods

  • Retrieves all data from the database.

    Returns Record<string, any>

    All data from the database.

  • Deletes a value from the database.

    Parameters

    • path: string

      The path to the value to be deleted.

    Returns void

  • Deletes all data from the database.

    Returns void

  • Filters the database based on a callback function.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • callback: ((key, value) => any)

      The callback function for filtering.

        • (key, value): any
        • Parameters

          • key: any
          • value: V[K]

          Returns any

    Returns any

    The filtered data.

  • Retrieves a value from the database.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The key for the value.

    Returns any

    The retrieved value.

  • Removes a value from an array in the database.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The key for the array.

    • value: V[K]

      The value to be removed.

    Returns void

  • Appends a value to an array in the database.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The key for the array.

    • value: V[K]

      The value to be appended.

    • Optional expirationSeconds: number

      The expiration time for the array in seconds.

    Returns void

  • Runs garbage collection to remove expired data.

    Returns void

  • Sets a value in the database.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The key for the value.

    • value: any

      The value to be stored.

    • Optional expirationSeconds: number

      The expiration time for the value in seconds.

    Returns void

  • Sets a value in the database with a time-to-live (TTL) expiration.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • key: K

      The key for the value.

    • value: V[K]

      The value to be stored.

    • ttl: number

      The time-to-live in milliseconds.

    • Optional callback: Function

      Callback function to be executed after the TTL expires.

    Returns void

  • Creates a snapshot of the current database state.

    Returns Record<string, V>

    The snapshot of the database.

Generated using TypeDoc