Support for store.has syscall
This commit is contained in:
parent
bc8d2d5e61
commit
d133c79de0
@ -31,6 +31,10 @@ export function get(key: string): Promise<any> {
|
||||
return syscall("store.get", key);
|
||||
}
|
||||
|
||||
export function has(key: string): Promise<boolean> {
|
||||
return syscall("store.has", key);
|
||||
}
|
||||
|
||||
export function del(key: string): Promise<void> {
|
||||
return syscall("store.delete", key);
|
||||
}
|
||||
|
@ -135,6 +135,13 @@ export function storeSyscalls(
|
||||
return null;
|
||||
}
|
||||
},
|
||||
"store.has": async (_ctx, key: string): Promise<boolean> => {
|
||||
const result = await db.query(
|
||||
`SELECT count(value) as cnt FROM ${tableName} WHERE key = ?`,
|
||||
key,
|
||||
);
|
||||
return result[0].cnt === 1;
|
||||
},
|
||||
"store.queryPrefix": async (_ctx, prefix: string) => {
|
||||
return (
|
||||
await db.query(
|
||||
|
@ -7,6 +7,7 @@ export function storeSyscalls(space: Space): SysCallMapping {
|
||||
[
|
||||
"store.queryPrefix",
|
||||
"store.get",
|
||||
"store.has",
|
||||
"store.set",
|
||||
"store.batchSet",
|
||||
"store.delete",
|
||||
|
Loading…
Reference in New Issue
Block a user