From 0ff005a59524b414a1795b542290c0eee1ef5794 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Sat, 13 Jan 2024 18:12:48 +0100 Subject: [PATCH] Add some datastore shortcuts --- plugos/lib/datastore.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugos/lib/datastore.ts b/plugos/lib/datastore.ts index 4af3b6e..076f4eb 100644 --- a/plugos/lib/datastore.ts +++ b/plugos/lib/datastore.ts @@ -23,6 +23,9 @@ export class DataStore { } batchGet(keys: KvKey[]): Promise<(T | null)[]> { + if (keys.length === 0) { + return Promise.resolve([]); + } return this.kv.batchGet(keys); } @@ -31,6 +34,9 @@ export class DataStore { } batchSet(entries: KV[]): Promise { + if (entries.length === 0) { + return Promise.resolve(); + } const allKeyStrings = new Set(); const uniqueEntries: KV[] = []; for (const { key, value } of entries) { @@ -50,6 +56,9 @@ export class DataStore { } batchDelete(keys: KvKey[]): Promise { + if (keys.length === 0) { + return Promise.resolve(); + } return this.kv.batchDelete(keys); }