From 6ad221ed36a0e4cd2268495f599cb02db91f5cbf Mon Sep 17 00:00:00 2001 From: Ludea Date: Mon, 12 Jun 2023 19:26:08 +0200 Subject: [PATCH] fix(stronghold): return null if there is no record (#129) * [stronghold] return null if there is no record * Return value * return statement * prettier * fix function signature * fix if condition * simplify condition --------- Co-authored-by: Fabian-Lars --- plugins/stronghold/guest-js/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/stronghold/guest-js/index.ts b/plugins/stronghold/guest-js/index.ts index 9272f9a9..26c03958 100644 --- a/plugins/stronghold/guest-js/index.ts +++ b/plugins/stronghold/guest-js/index.ts @@ -293,12 +293,18 @@ export class Store { this.client = client; } - async get(key: StoreKey): Promise { + async get(key: StoreKey): Promise { return await invoke("plugin:stronghold|get_store_record", { snapshotPath: this.path, client: this.client, key: toBytesDto(key), - }).then((v) => Uint8Array.from(v)); + }).then((v) => { + if (v) { + return Uint8Array.from(v); + } else { + return null; + } + }); } async insert(