import { AbstractLevel, AbstractDatabaseOptions, NodeCallback, AbstractOpenOptions, AbstractGetOptions, AbstractGetManyOptions, AbstractPutOptions, AbstractDelOptions, AbstractBatchOptions, AbstractChainedBatch, AbstractIterator, AbstractKeyIterator, AbstractValueIterator, AbstractIteratorOptions, AbstractKeyIteratorOptions, AbstractValueIteratorOptions, AbstractBatchOperation } from 'abstract-level' /** * An {@link AbstractLevel} database for browsers, backed by [IndexedDB][1]. * * @template KDefault The default type of keys if not overridden on operations. * @template VDefault The default type of values if not overridden on operations. * * [1]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API */ export class BrowserLevel extends AbstractLevel { /** * Database constructor. * * @param location The name of the [`IDBDatabase`](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase) * to be opened, as well as the name of the object store within that database. The name * of the `IDBDatabase` will be prefixed with {@link DatabaseOptions.prefix}. * @param options Options, of which some will be forwarded to {@link open}. */ constructor (location: string, options?: DatabaseOptions | undefined) /** * Location that was passed to the constructor. */ get location (): string /** * Database name prefix that was passed to the constructor (as `prefix`). */ get namePrefix (): string /** * Version that was passed to the constructor. */ get version (): number /** * Delete the IndexedDB database at the given {@link location}. */ static destroy (location: string): Promise static destroy (location: string, prefix: string): Promise static destroy (location: string, callback: NodeCallback): void static destroy (location: string, prefix: string, callback: NodeCallback): void } /** * Options for the {@link BrowserLevel} constructor. */ export interface DatabaseOptions extends AbstractDatabaseOptions { /** * Prefix for the `IDBDatabase` name. Can be set to an empty string. * * @defaultValue `'level-js-'` */ prefix?: string /** * The version to open the `IDBDatabase` with. * * @defaultValue `1` */ version?: number | string /** * An {@link AbstractLevel} option that has no effect on {@link BrowserLevel}. */ createIfMissing?: boolean /** * An {@link AbstractLevel} option that has no effect on {@link BrowserLevel}. */ errorIfExists?: boolean } // Export types so that consumers don't have to guess whether they're extended export type OpenOptions = AbstractOpenOptions export type GetOptions = AbstractGetOptions export type GetManyOptions = AbstractGetManyOptions export type PutOptions = AbstractPutOptions export type DelOptions = AbstractDelOptions export type BatchOptions = AbstractBatchOptions export type BatchOperation = AbstractBatchOperation export type ChainedBatch = AbstractChainedBatch export type Iterator = AbstractIterator export type KeyIterator = AbstractKeyIterator export type ValueIterator = AbstractValueIterator export type IteratorOptions = AbstractIteratorOptions export type KeyIteratorOptions = AbstractKeyIteratorOptions export type ValueIteratorOptions = AbstractValueIteratorOptions