A DataProvider implemented with a Level backend.

Hierarchy

  • DataProvider
    • LevelDataProvider

Implements

  • ClearableDataProvider

Constructors

  • Parameters

    • client: ExtendedClient

      The client that this data provider will be used by.

    • location: string

      The fully resolved path where the Level database will be saved. This must resolve to a directory.

    Returns LevelDataProvider

Properties

client: ExtendedClient

The client that this data provider will be used by.

Memberof

DataProvider

db: Level<string, unknown>

The Level instance for this data provider.

Memberof

LevelDataProvider

Methods

  • Private

    Clear all data that start with the given pattern.

    Parameters

    • startsWith: string

      The pattern to look for the keys to delete.

    Returns Promise<void>

    A promise that resolves once all data has been deleted.

  • Private

    Delete a value stored for a given absolute key.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be set.

    Returns Promise<undefined | T>

    A promise that resolves once the data has been deleted.

  • Private

    Get a value for a given absolute key.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Private

    Get a value for a given absolute key.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    • defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<T>

    A promise that resolves the queried data.

  • Private

    Set a value for an absolute key.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be set.

    • value: T

      The value to set.

    Returns Promise<void>

    A promise that resolves once the data is saved.

  • Clear all data in a guild.

    Parameters

    • guild: Guild

      The guild to clear the data from.

    Returns Promise<void>

    A promise that resolves once all data has been deleted.

    Emits

    client#dataProviderClear

  • Clear all data in a global scope.

    Returns Promise<void>

    A promise that resolves once all data has been deleted.

    Emits

    client#dataProviderClear

  • Delete a key-value pair in a guild.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the key-value pair will be deleted.

    • key: string

      The key to delete.

    Returns Promise<undefined | T>

    A promise that resolves the data that has been deleted.

  • Delete a key-value pair in a global scope.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key to delete.

    Returns Promise<undefined | T>

    A promise that resolves the data that has been deleted.

  • Gracefully destroy this Level data provider. This closes the database connection. Once this is called, this data provider will be unusable.

    Returns Promise<void>

    A promise that resolves once this data provider is destroyed.

    Emits

    client#dataProviderDestroy

  • Get a value for a key in a guild.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be queried.

    • key: string

      The key of the data to be queried.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Get a value for a key in a guild.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be queried.

    • key: string

      The key of the data to be queried.

    • defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<T>

    A promise that resolves the queried data.

  • Get a value for a key in a global scope.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    Returns Promise<undefined | T>

    A promise that resolves the queried data.

  • Get a value for a key in a global scope.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be queried.

    • defaultValue: T

      The default value in case there is no entry found.

    Returns Promise<T>

    A promise that resolves the queried data.

  • Initialize this Level data provider. This opens the database connection and creates the data directory in case it does not exist yet.

    Returns Promise<LevelDataProvider>

    A promise that resolves this Level data provider once it's ready.

    Emits

    client#dataProviderInit

  • Private

    Resolve the key for the provided guild or for the global scope if not provided.

    Parameters

    • key: string

      The key to resolve.

    • Optional guild: Guild

      The guild for which the key will be resolved.

    Returns string

    The resolved key.

  • Set a value for a key in a guild.

    Type Parameters

    • T = any

    Parameters

    • guild: Guild

      The guild for which the data will be set.

    • key: string

      The key of the data to be set.

    • value: T

      The value to set.

    Returns Promise<void>

    A promise that resolves once the data is saved.

  • Set a value for a key in a global scope.

    Type Parameters

    • T = any

    Parameters

    • key: string

      The key of the data to be set.

    • value: T

      The value to set.

    Returns Promise<void>

    A promise that resolves once the data is saved.

Generated using TypeDoc