Storage
Zipper provides basic, built-in key-value storage. Each applet has its own unique storage instance. Forked applets each have their unique storage instance too.
To access your applet storage, use the Zipper.storage
global.
getAll
getAll
returns an object with all the keys and values in storage. If there is nothing in storage, it returns null
.
const everything = await Zipper.storage.getAll();
get
get
returns the stored value for a given key. You do not need to worry about unserializing. If the key has not been set, get
will return null
.
const singleValue = await Zipper.storage.get('some_key_name');
You can also cast objects:
const myStringArray = await Zipper.storage.get<string[]>('some_key_name');
set
set
sets a key with a given value. You do not need to worry about serializing. The method will take care of that for you.
await Zipper.storage.set('some_key_name', { foo: 'bar' });
delete
delete
deletes a key-value pair for a given key.
await Zipper.storage.delete('some_key_name');