Interface IDatabaseTable<T>

Interface for a key-value database table.

interface IDatabaseTable<T> {
    add(value: ValueTypeOmitId<T>): Promise<T>;
    clear(): Promise<void>;
    count(query?: IDatabaseTableQuery | IQueryBuilder): Promise<number>;
    delete(key: string): Promise<void>;
    get(key: string): Promise<undefined | T>;
    list(query?: IDatabaseTableQuery | IQueryBuilder): Promise<T[]>;
    set(key: string, value: ValueTypeOmitId<T>): Promise<T>;
    subscribe(callback: ((event: IDatabaseTableEvent<T>) => void)): void;
    unsubscribe(): void;
}

Type Parameters

Methods

  • Add a value to the database.

    Parameters

    Returns Promise<T>

    A promise that resolves with the value added.

  • Clear the database.

    Returns Promise<void>

    A promise that resolves when the database has been cleared.

  • Count the number of keys in the database.

    Parameters

    Returns Promise<number>

    A promise that resolves with the number of keys in the database.

  • Delete a key.

    Parameters

    • key: string

      The key to delete.

    Returns Promise<void>

    A promise that resolves when the key has been deleted.

  • Get the value for a key.

    Parameters

    • key: string

      The key to get the value for.

    Returns Promise<undefined | T>

    A promise that resolves with the value for the key.

  • Set the value for a key.

    Parameters

    Returns Promise<T>

    A promise that resolves with the value set.

  • Subscribe to changes in the database table.

    Parameters

    Returns void

    callback The callback to call when the database table changes.

  • Unsubscribe from changes in the database table.

    Returns void