-
Notifications
You must be signed in to change notification settings - Fork 124
/
ikv-store.ts
37 lines (33 loc) · 884 Bytes
/
ikv-store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export type StoreSearchParams = {
reverse: boolean
limit: number
gte: string
lte: string
gt: string
lt: string
}
export type IKVStoreFindResult = {
key: string
value: any
}
export interface ChainedKVBatch {
put(key: string, value: string): this
del(key: string): this
clear(): this
write(): Promise<void>
}
export interface IKVStore {
close(): Promise<void>
isEmpty(params?: Partial<StoreSearchParams>): Promise<boolean>
findKeys(params?: Partial<StoreSearchParams>): Promise<Array<string>>
find(params?: Partial<StoreSearchParams>): Promise<Array<IKVStoreFindResult>>
exists(key: string): Promise<boolean>
put(key: string, value: any): Promise<void>
get(key: string): Promise<any>
del(key: string): Promise<void>
batch(): ChainedKVBatch
}
export interface IKVFactory {
open(name?: string): Promise<IKVStore>
close(): Promise<void>
}