Improve archive db types
(cherry picked from commit 80e4959ba2aa00c984c26aed2f7dfae1095720b0)
This commit is contained in:
committed by
Samuel Newman
parent
ab8d14a1f0
commit
1b6b02c0df
@@ -6,16 +6,16 @@ export function create({id}: {id: string}): DB {
|
|||||||
const store = new MMKV({id})
|
const store = new MMKV({id})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async get(key: string): Promise<string | undefined> {
|
get(key: string) {
|
||||||
return store.getString(key)
|
return store.getString(key)
|
||||||
},
|
},
|
||||||
async set(key: string, value: string): Promise<void> {
|
set(key: string, value: string) {
|
||||||
return store.set(key, value)
|
return store.set(key, value)
|
||||||
},
|
},
|
||||||
async delete(key: string): Promise<void> {
|
delete(key: string) {
|
||||||
return store.delete(key)
|
return store.delete(key)
|
||||||
},
|
},
|
||||||
async clear(): Promise<void> {
|
clear() {
|
||||||
return store.clearAll()
|
return store.clearAll()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ export function create({id}: {id: string}): DB {
|
|||||||
const store = createStore(id, id)
|
const store = createStore(id, id)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async get(key: string): Promise<string | undefined> {
|
get(key: string) {
|
||||||
return get(key, store)
|
return get(key, store)
|
||||||
},
|
},
|
||||||
async set(key: string, value: string): Promise<void> {
|
set(key: string, value: string) {
|
||||||
return set(key, value, store)
|
return set(key, value, store)
|
||||||
},
|
},
|
||||||
async delete(key: string): Promise<void> {
|
delete(key: string) {
|
||||||
return del(key, store)
|
return del(key, store)
|
||||||
},
|
},
|
||||||
async clear(): Promise<void> {
|
clear() {
|
||||||
return clear(store)
|
return clear(store)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
type MaybePromise<T> = T | Promise<T>
|
||||||
export type DB = {
|
export type DB = {
|
||||||
get(key: string): Promise<string | undefined>
|
get(key: string): MaybePromise<string | undefined>
|
||||||
set(key: string, value: string): Promise<void>
|
set(key: string, value: string): MaybePromise<void>
|
||||||
delete(key: string): Promise<void>
|
delete(key: string): MaybePromise<void>
|
||||||
clear(): Promise<void>
|
clear(): MaybePromise<void>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user