1
0
silverbullet/syscall/silverbullet-syscall/index.ts

55 lines
1.3 KiB
TypeScript
Raw Normal View History

import type { Query } from "../plugos-syscall/store.ts";
import { syscall } from "./syscall.ts";
2022-04-01 15:07:08 +00:00
export type KV = {
key: string;
value: any;
};
export function set(
2022-04-01 15:07:08 +00:00
page: string,
key: string,
value: any,
2022-04-01 15:07:08 +00:00
): Promise<void> {
return syscall("index.set", page, key, value);
}
export function batchSet(page: string, kvs: KV[]): Promise<void> {
2022-04-01 15:07:08 +00:00
return syscall("index.batchSet", page, kvs);
}
export function get(page: string, key: string): Promise<any> {
2022-04-01 15:07:08 +00:00
return syscall("index.get", page, key);
}
export function del(page: string, key: string): Promise<void> {
2022-04-01 15:07:08 +00:00
return syscall("index.delete", page, key);
}
export function queryPrefix(
prefix: string,
2022-04-01 15:07:08 +00:00
): Promise<{ key: string; page: string; value: any }[]> {
return syscall("index.queryPrefix", prefix);
2022-04-01 15:07:08 +00:00
}
export function query(
query: Query,
2022-04-01 15:07:08 +00:00
): Promise<{ key: string; page: string; value: any }[]> {
return syscall("index.query", query);
2022-04-01 15:07:08 +00:00
}
export function clearPageIndexForPage(page: string): Promise<void> {
2022-04-01 15:07:08 +00:00
return syscall("index.clearPageIndexForPage", page);
}
export function deletePrefixForPage(
2022-04-01 15:07:08 +00:00
page: string,
prefix: string,
2022-04-01 15:07:08 +00:00
): Promise<void> {
return syscall("index.deletePrefixForPage", page, prefix);
}
export function clearPageIndex(): Promise<void> {
2022-04-01 15:07:08 +00:00
return syscall("index.clearPageIndex");
}