[Solved] Dynamically Reference of DatasourceTables

Hi Thunkers!

I’m looking a way to dynamically choose the name of the Datasource’s table when creating / getting / deleting rows locally, as also create new tables during the app session, but the current blocks doesn’t allow to do it, only use the pre-defined tables, “hard coding” the create / get / delete actions.

Please let me know if you know any hack or another approach to make it work (storing data buckets for offline apps, maybe save/read locally a JSON file)?.

1 Like

You can store data in variables as Json trees. You could do things that way perhaps? Dynamic branches within 1 variable.

1 Like

humm… I hadn’t thought of that…but it looks like a solution!

But how to initialize stored variables dynamically? I mean, I will need to do CRUD operations with stored variables to keep different data locally (create/read/update/delete these variables) and the “initialize” block is not customizable, only the “set” block.

But if I choose to use a single Variable the size o Json will the increase, so my first idea was to create dinamically different variables to store a limited number of buckets.

Anyway I’m going to do some tests to check how to manipulate Json, and for that, I’ll have to develop functions for reading and writing, but I believe it’s quite easy to do.

the only downside may be that for larger volumes of data there may be considerable delays in writing / retrieving the whole data each time some Json object is updated.

[UPDATE]

I can create a Stored Variable as a LIST… So the problem can be solved! I can save a different JSON for each list Item. Of course I’ll have some overhead in the reading / saving process.

2 Likes

Yes, I was going to recommend a list in a stored variable.

3 Likes

If you start to do this then consider saving your data in Firebase instead of stored variables specially if you wan the data to be user specific because you can save the data under the Logged In user ID.

It is more of a use case dependent.

The point here is that is an offline APP, with very limited access to Firebase to use on poor internet signal regions, so I will sync with Firebase only when online. Meanwhile I need to save the data collected in the app to save later.

1 Like