How to store data / list that wont change?

Hi everyone,

quick question - I have a list of every country in the world incl. its ISO code. What is the best way of storing this in Weweb? It doesn’t make much sense to put it in a database like Supabase since its most likely not gonna change. Can I store this in an array variable or is there a better way?

the current format looks like this: [{‘Country’: ‘Zimbabwe’, ‘ISO Code’: ‘ZW’}, {‘Country’: ‘Zambia’, ‘ISO Code’: ‘ZM’},…]

Thanks :slight_smile:
Seb

You can store it in a variable. I’d suggest a CAPITAL naming convention, so it would be: COUNTRIES
capitals usually are used to signify constant immutable values in conventional development :slight_smile: But yeah, a variable will do.

It would be better if we could store an read JSONs in a WeWeb project (@Alexis this might be a cool feature to throw somewhere in the backlog of the backlog, if that even would be aligned with the direction of WeWeb).

This might also be possible by hosting the file on the CDN, but yeah, that seems like too much work :slight_smile: A variable would do.

3 Likes

Hi @sebschaeffer, yes you can create a variable :slight_smile:

From what I understand what should be added there is a Readonly toggle on variables, should be enough as a good practice, right ? @Broberto

I’m not sure how WeWeb stores variables under the hood, so that’s up to you to tell me haha. Like, I don’t even think if there is a need for readonly toggle, even if it would be a nice feature. My concern was more like, performance-wise, but if you say it’s cool, then it’s cool :slight_smile: