1
0
silverbullet/web/syscalls/clientStore.ts

21 lines
672 B
TypeScript
Raw Normal View History

import { SysCallMapping } from "../../plugos/system.ts";
import { DataStore } from "../../plugos/lib/datastore.ts";
import { KvKey } from "$sb/types.ts";
2022-04-04 13:25:07 +00:00
export function clientStoreSyscalls(
ds: DataStore,
prefix: KvKey = ["client"],
): SysCallMapping {
return {
"clientStore.get": (ctx, key: string): Promise<any> => {
return ds.get([...prefix, ctx.plug!.name!, key]);
},
"clientStore.set": (ctx, key: string, val: any): Promise<void> => {
return ds.set([...prefix, ctx.plug!.name!, key], val);
},
"clientStore.delete": (ctx, key: string): Promise<void> => {
return ds.delete([...prefix, ctx.plug!.name!, key]);
},
};
2022-04-04 13:25:07 +00:00
}