2024-03-16 22:29:24 +08:00
|
|
|
import { syscall } from "../syscall.ts";
|
2024-02-29 22:23:05 +08:00
|
|
|
import { KV, KvKey, KvQuery } from "../types.ts";
|
2023-10-03 20:16:33 +08:00
|
|
|
|
|
|
|
export function set(key: KvKey, value: any): Promise<void> {
|
|
|
|
return syscall("datastore.set", key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function batchSet(kvs: KV[]): Promise<void> {
|
|
|
|
return syscall("datastore.batchSet", kvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function get(key: KvKey): Promise<any> {
|
|
|
|
return syscall("datastore.get", key);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function batchGet(keys: KvKey[]): Promise<(any | undefined)[]> {
|
|
|
|
return syscall("datastore.batchGet", keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function del(key: KvKey): Promise<void> {
|
|
|
|
return syscall("datastore.delete", key);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function batchDel(keys: KvKey[]): Promise<void> {
|
|
|
|
return syscall("datastore.batchDelete", keys);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function query(
|
|
|
|
query: KvQuery,
|
2024-02-03 02:19:07 +08:00
|
|
|
variables: Record<string, any> = {},
|
2023-10-03 20:16:33 +08:00
|
|
|
): Promise<KV[]> {
|
2024-02-03 02:19:07 +08:00
|
|
|
return syscall("datastore.query", query, variables);
|
2023-10-03 20:16:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function queryDelete(
|
|
|
|
query: KvQuery,
|
2024-02-03 02:19:07 +08:00
|
|
|
variables?: Record<string, any>,
|
2023-10-03 20:16:33 +08:00
|
|
|
): Promise<void> {
|
2024-02-03 02:19:07 +08:00
|
|
|
return syscall("datastore.queryDelete", query, variables);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function listFunctions(): Promise<string[]> {
|
|
|
|
return syscall("datastore.listFunctions");
|
2023-10-03 20:16:33 +08:00
|
|
|
}
|