How do you cache/store a List of objects? (want to make app available offline)

I would like to store the repeated group information in phones cache or anywhere effficient so that when the user goes into the app with internet connection that it will save the current content in the event they reopen the app offline.

Currently if the user has no internet the content dissappears and also if they have slow internet images loads slow clumsy.

Regards,

1 Like

Hi Nicole!

I would use a client-side data collection and app variables to achieve this. When the app launches, I would check on the Global Canvas whether the user’s device is online or not, and then populate an app variable with data from either your online resource or a client-side storage resource.

To make the client-side storage work, I would:

  1. Create a new client-side resource and an app variable with a schema exactly matching the object in your current database
  2. Initialize the client-side storage resource on the Global Canvas if it does not yet exist (i.e. when launching the app for the first time) using Set item to storage
  3. When the app launches, use an If condition flow function on the Global Canvas to populate the app variable with data from either the client-side collection (Get item from storage) or the online resource based on the value of systemVars.networkStatus (You can find the documentation here: https://docs.appgyver.com/reference/system-variables)
  4. If the device is online, update the client-side collection record with the newest data using Replace client-side collection flow function (available in the marketplace)

Hope this helps!

Mari

HI Mari,

I followed what you say but since i am storing a list of objects, get item from storage doesn’t work.

Is get item from storage the same as client storage, there seem to be a mix up with that.

also get item from storage does not seem to be accepting the list type.

i use Airtable for my records with a get collection logic for my database. Please show an example. in picture form of what you said.

APP ID

272493

Hi Nicole, you’re right, sorry for the mixup! In case of lists, you can create a client-side storage resource that has the following properties:

  1. ID
  2. list (a list of objects with the schema exactly matching your Airtable for storing the data)

On the Global Canvas, I would implement the logic like this:

  1. Get record collection (Airtable)
  2. If successful, set the app variable to use data from your Airtable. Also update the client-side storage resource, binding the output of the Get record collection node to the “list” property.
  3. If Update record fails (the record with your chosen ID does not yet exist), Create record with an ID of your choice and bind the “list” to output of Get record collection. Now you should have a local copy of your data.
  4. If Get record collection fails (no internet or some other issue), use Get record to fetch the client-side resource and use it in the app variable.

When using the Create/Update/Get record flow functions you can pick any ID for the client-side resource you use to save your data, just make sure that it is the same all around :slight_smile:

Hi Maria my current issue is that the client storage don’t read the exact list of objects, as i have the exact same schemer as my app variable which reads well.

I have tried several different paths
It says list of objects with 3 properties is not compatible with list of objects with 2 properties

Hi Travis, that does sound odd. Maybe you have an extra id property or something in the client storage resource? Could you share screenshots of your data resource scheme and the client-side storage scheme where the object properties are visible?

I used the formula now because it goes through but it provides an error. below is the error for update record and create record logic.

below is when i try it with output from another node. though it says object with 3 properties, I have a list of objects with 3 properties.

Hi Nicole, based on the error message it looks like your client-side scheme might have an “object with 3 properties” instead of a “list of objects with 3 properties”. Check that the value type of your object property is “List” and the list item type is “Object”, like in this example:

1 Like

Hi Maria,

I have noticed that the client side storage puts everything into a Record and calls that Record Object type with 1 default id property. Therefore if you add a list to it, you get object type with 2 properties(your list and the id being the 2 properties).

Record [object with 2 properties]
id(default) — [property1]
Records [list of objects with 3 properties] — [property2]
fields [list of objects with 7 properties] — [property]
id — [property1]
id — [property8]
name — [property]
name— [property]

Hi Nicole! I discovered that the trick here is to make the app variable scheme match that of the client-side resource.

Resources & variables

REST API resource:

Local resource:

App variable:

Operations on Global canvas

In Update Record, I bind the output of the Get record collection node to the list of objects in Local resource by clicking “Custom object” under Record properties:

In Create Record, doing the same and also adding the ID ‘SOMEID’ that I already used in Update record (this can be any ID of your choice, as long as you use the same one across all nodes).

I also use the same ID in the inputs of “Get Record”.

Since the App variable matches the Client-side resource scheme, binding it to the Response object of the Update/Get/Create record output now works:

1 Like

can you come unto my app – APP ID = 272493

With airtable the records in the schema are populated as list.

fields [list of object]

object1
object2
object3

i see that you have them as

object1
object2
object3

which makes a difference in how it is setup.
i was close to getting it until the app variables stated incompatible list

Any ETA on this, looking to accomplish this Asap as our team is launching the app Sunday.

please let me know if anything is needed.

Regards,

Hi Nicole, I’ve requested access to your app. I’ll get back to the topic tomorrow.

OK GREAT, Thanks, for your assistance.

Good day,

I would like to know what time is good for you to take a look at our app.

Regards,

Hi Nicole, I got into your app and will take a look in 5 minutes! Are you still experiencing the same issue?

Hi Maria, Yes i am experiencing the same issue. ok great thanks.

Hi Nicole, took me long enough to find the bug but I managed to fix the issue! :relaxed: :relaxed: In your Record app variable you had fields as a “list of objects with 7 properties”, when it should have been an “object with 7 properties” as it is in the REST API response. That’s why the schemes of the app variable and the data variables didn’t match.

Ok wonderful thanks very much for your assistance im looking into it, will get back with you shortly.

When i try to populate the records i get these which is suppose to look like this below.