import { IDatabaseTableQuery, ValueTypeOmitId, IValueType, IDatabaseTableEvent, IQueryBuilder } from '.'; /** * Interface for a key-value database table. * @category Key-Value Database */ export interface IDatabaseTable { /** * Get the value for a key. * @param key The key to get the value for. * @returns A promise that resolves with the value for the key. */ get(key: string): Promise; /** * Set the value for a key. * @param key The key to set the value for. * @param value The value to set for the key. It must be {@link https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects | serializable }. * @returns A promise that resolves with the value set. */ set(key: string, value: ValueTypeOmitId): Promise; /** * Add a value to the database. * @param value The value to add. * @returns A promise that resolves with the value added. */ add(value: ValueTypeOmitId): Promise; /** * Delete a key. * @param key The key to delete. * @returns A promise that resolves when the key has been deleted. */ delete(key: string): Promise; /** * Clear the database. * @returns A promise that resolves when the database has been cleared. */ clear(): Promise; /** * Get all the values in the database. * @param query The query to use to filter the values. * If no query is provided, all the values in the database are returned. * The query can either be a {@link IDatabaseTableQuery} or a {@link QueryBuilder}. * @returns A promise that resolves with all the values in the database. */ list(query?: IDatabaseTableQuery | IQueryBuilder): Promise; /** * Count the number of keys in the database. * @param query The query to use to filter the keys. * If no query is provided, all the keys in the database are counted. * The query can either be a {@link IDatabaseTableQuery} or a {@link QueryBuilder}. * @returns A promise that resolves with the number of keys in the database. */ count(query?: IDatabaseTableQuery | IQueryBuilder): Promise; /** * Subscribe to changes in the database table. * @param callback The callback to call when the database table changes. */ subscribe(callback: (event: IDatabaseTableEvent) => void): void; /** * Unsubscribe from changes in the database table. */ unsubscribe(): void; }