1 |
|
2 | import type { LevelUp } from 'levelup';
|
3 | export declare const ENCODING_OPTS: {
|
4 | keyEncoding: string;
|
5 | valueEncoding: string;
|
6 | };
|
7 | export declare type BatchDBOp = PutBatch | DelBatch;
|
8 | export interface PutBatch {
|
9 | type: 'put';
|
10 | key: Buffer;
|
11 | value: Buffer;
|
12 | }
|
13 | export interface DelBatch {
|
14 | type: 'del';
|
15 | key: Buffer;
|
16 | }
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export declare class DB {
|
22 | _leveldb: LevelUp;
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 | constructor(leveldb?: LevelUp);
|
29 | /**
|
30 | * Retrieves a raw value from leveldb.
|
31 | * @param key
|
32 | * @returns A Promise that resolves to `Buffer` if a value is found or `null` if no value is found.
|
33 | */
|
34 | get(key: Buffer): Promise<Buffer | null>;
|
35 | /**
|
36 | * Writes a value directly to leveldb.
|
37 | * @param key The key as a `Buffer`
|
38 | * @param value The value to be stored
|
39 | */
|
40 | put(key: Buffer, val: Buffer): Promise<void>;
|
41 | /**
|
42 | * Removes a raw value in the underlying leveldb.
|
43 | * @param keys
|
44 | */
|
45 | del(key: Buffer): Promise<void>;
|
46 | /**
|
47 | * Performs a batch operation on db.
|
48 | * @param opStack A stack of levelup operations
|
49 | */
|
50 | batch(opStack: BatchDBOp[]): Promise<void>;
|
51 | /**
|
52 | * Returns a copy of the DB instance, with a reference
|
53 | * to the **same** underlying leveldb instance.
|
54 | */
|
55 | copy(): DB;
|
56 | }
|