2023-10-03 13:24:07 +00:00
|
|
|
import { KV, KvQuery, ObjectQuery, ObjectValue } from "$sb/types.ts";
|
2023-10-03 12:16:33 +00:00
|
|
|
import { invokeFunction } from "$sb/silverbullet-syscall/system.ts";
|
|
|
|
|
|
|
|
export function indexObjects<T>(
|
|
|
|
page: string,
|
|
|
|
objects: ObjectValue<T>[],
|
|
|
|
): Promise<void> {
|
|
|
|
return invokeFunction("index.indexObjects", page, objects);
|
|
|
|
}
|
|
|
|
|
2023-10-03 13:24:07 +00:00
|
|
|
export function batchSet(page: string, kvs: KV[]): Promise<void> {
|
|
|
|
return invokeFunction("index.batchSet", page, kvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function query(
|
|
|
|
query: KvQuery,
|
|
|
|
): Promise<KV[]> {
|
|
|
|
return invokeFunction("index.query", query);
|
|
|
|
}
|
|
|
|
|
2023-10-03 12:16:33 +00:00
|
|
|
export function queryObjects<T>(
|
|
|
|
tag: string,
|
|
|
|
query: ObjectQuery,
|
|
|
|
): Promise<ObjectValue<T>[]> {
|
|
|
|
return invokeFunction("index.queryObjects", tag, query);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getObjectByRef<T>(
|
|
|
|
page: string,
|
|
|
|
tag: string,
|
|
|
|
ref: string,
|
2023-11-06 08:14:16 +00:00
|
|
|
): Promise<T | undefined> {
|
2023-10-03 12:16:33 +00:00
|
|
|
return invokeFunction("index.getObjectByRef", page, tag, ref);
|
|
|
|
}
|