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 <fabianlars@fabianlars.de>
This commit is contained in:
Ludea
2023-06-12 19:26:08 +02:00
committed by GitHub
co-authored by Fabian-Lars
parent 0984fc8374
commit 6ad221ed36
+8 -2
View File
@@ -293,12 +293,18 @@ export class Store {
this.client = client; this.client = client;
} }
async get(key: StoreKey): Promise<Uint8Array> { async get(key: StoreKey): Promise<Uint8Array | null> {
return await invoke<number[]>("plugin:stronghold|get_store_record", { return await invoke<number[]>("plugin:stronghold|get_store_record", {
snapshotPath: this.path, snapshotPath: this.path,
client: this.client, client: this.client,
key: toBytesDto(key), key: toBytesDto(key),
}).then((v) => Uint8Array.from(v)); }).then((v) => {
if (v) {
return Uint8Array.from(v);
} else {
return null;
}
});
} }
async insert( async insert(