Key-Value Storage Zome, a simple general "database" for Holochain apps

Hi! I finally got up and running on my Mac :slight_smile: and spent a few evenings learning RSM and creating this. The developer experience with HDK3/RSM is starting to feel really good - super fast compile times etc!

Key-Value Storage Zome

A Zome for persisting key/value pairs - a simple general “database” for Holochain apps. The API is very close to the Web storage specifications for localStorage and sessionStorage

There is no sample UI yet but I hope to be able to add that in the near future. Have a look at the tests also, they run through all functionality.

Functions
create_store Creates a named key/value store.
get_store Returns store information, or error if no store with the given name.
set_item Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
get_item Returns the current value associated with the given key, or error if the given key does not exist.
remove_item Removes the key/value pair with the given key, if a key/value pair with the given key exists.
length Returns the number of keys in the store
keys Returns a list with all the keys in the store
key Returns the name of the nth key, or Error if n is greater than or equal to the number of key value pairs.
clear Removes all key/value pairs, if there are any.
4 Likes

Uhh I like it! Adding you to the org.

I can envision using this as a foundation for different simple things, although indexing can’t be optimized for different use cases - I think this is the biggest disadvantage. Overall really cool to have.

What do you envision as UI functionality? Services that expose the api or full-fledged elements?

Thanks! I moved the repo.

Yep, that’s the intention. :slight_smile: Just as localStorage and sessionStorage are general storage solutions for web apps, this zome could serve a similar need for hApps. Sometimes storing stuff in the client is ok even for hApps but sometimes you want to persist the data to be able to move between devices etc. And I’m thinking the same kind of data you would store in localStorage: settings, session data, state data, etc.

One brand of future holochain apps will probably be static apps that run 98% in the client, served by IPFS or holo.host. Holochain in this case mostly serves as a source of persistent storage. Not a super sexy task maybe, but super valuable. You could do this sort of thing on IPFS today but doing it on Holochain will be way better :rainbow::+1:.

Services that expose the API mostly. UI would only be for showcasing functionality and trying out ideas on how to best build the UI and connect it to holochain. I have been following your work with webcomponents and graphql at a distance but will take a closer look now.

thanks for doing this. hmu if you ever wanna talk dev stuff :v:
much love

1 Like