How to use a key/value data store

Am I blind or there’s no way to make dictionary-like storage?

key-value are essential for my project.
I’d like to have it on the client-side: I tried using data store but it seems like it isn’t made for key-value parameters.

Any tips?

Sorry I’m not familiar with ‘dictionary-like storage’. But almost everything with Wappler is key-value based. So can you give an example of what you’d like to do?

Something like this:

key:1
value: Hey!

key: 2
value: What’s up?

retrieve key 1+key 2, result = Hey!What’s up?

I need to display a title on the screen, based on a variable which contains these numbers (1,2)

Keyed objects were covered for translation purposes, could easily be adapted, has some good information in this thread:

1 Like

This is not client-side, so I’d have to make a database request each time

Should work with the data store? Maybe @George or @Teodor could offer some direction for you.

Welcome to Wappler by the way! Am sure an answer to your question will come about shortly @panoc75392

Hope this helps:

  1. Create a datastore

  2. Populate the datastore with a button

  3. Print the data on the page using

{{view.datastore1.data[0][1]}}
{{view.datastore1.data[0][2]}}
  1. Result:

Tip: use this in the console to debug what’s inside your data store:

dmx.app.data.view.datastore1.data

Note: sometimes it’s ...data.view other times it is ...data.content for me, so you might have to replace it

2 Likes

Exactly this, what I was looking for.

Instead of a button, I added a Flow with Auto Run so that when the page loads, it writes all the data into the datastore.

Thank you @karh

1 Like

You’re welcome :smiley:

Glad it helped!

Out of curiousity: what kind of data are you using this for? I’m loading everything from the database or just hard code it into the page.

I needed it to be hard-coded into the page in this case.

1 Like