Interface IKeyValueDatabaseTableConnector<T>

The key-value database table connector interface.

interface IKeyValueDatabaseTableConnector<T> {
    add(value: ValueTypeOmitId<T>): Promise<T>;
    calculateSize(): Promise<number>;
    clear(): Promise<void>;
    count(query?: IDatabaseTableQuery): Promise<number>;
    delete(key: string): Promise<void>;
    get(key: string): Promise<undefined | T>;
    list(query?: IDatabaseTableQuery): Promise<T[]>;
    set(key: string, value: ValueTypeOmitId<T>): Promise<T>;
}

Type Parameters

Methods

  • Calculate the size of the table.

    Returns Promise<number>

    A promise that resolves with the size of the table in bytes.

  • Clear the database. Fires a IDatabaseTableEvent for each key deleted.

    Returns Promise<void>

    A promise that resolves when the database has been cleared.

  • Count the number of keys matching the query in the database.

    Parameters

    • Optionalquery: IDatabaseTableQuery

      The query to use to filter the keys. If no query is provided, all the keys in the database are counted.

    Returns Promise<number>

    A promise that resolves with the number of keys matching the query.

  • 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, or undefined if the key was not found.

  • Get all the values matching the query in the database.

    Parameters

    • Optionalquery: IDatabaseTableQuery

      The query to use to filter the values. If no query is provided, all the values in the database are returned.

    Returns Promise<T[]>

    A promise that resolves with all the values matching the query.