How can I save a Record Collection Locally?

I can’t figure out what is going wrong here. I have a small list of data on FireStore that I want the App to Grab and save to a local memory on the phone. However, I cannot assign the output of the Get Record Collection function: “The Type List of Object with 3 Properties is not compatible with The Type List of Object with 3 Properties.” Which doesn’t seem to make any sense.

The Firestore list is very small, with several objects with a Description, Time, and Id. I made a Local Data object with the same parameters and I am trying to save the Get Record Collection output into the Data variable for the local storage. Is there some formula I should be using? The Get Record Collection doesn’t have too many outputs, so I can’t seem to map Id to Id and Description to Description.

image

Hi Rob,

Instead of using variables rather use a client database.

I have done the same on my app. When I connect my app to Firebase I save the items locally as a sync command for offline use.

I hope this helps you


Thank you! I didn’t realize that was an option! Do the Databases need to have the same format?

Did you figure out how the schema of local storage you are pushing the records into should look like?

I’m stuck at the same point. I can read from Firebase but when I do the replace entire client side record collection into local storage, I’m getting no records from there.

Edit:

After some testing I found this difference between items stored in local storage from app interface and from component “Replace client side record collection”.

Key for items stored from app interface: local-resource:368756:<DATA_RESOURCE_ID>:
Key for items stored from app interface: @appgyverApp/368756/default/local-resource:<DATA_RESOURCE_ID>:

OK that was simple fix but no idea if I did it right. :slight_smile:

I double clicked the component and edited JS file on line 4:

//const keyPrefix = local-resource:${appId}:${resourceName}:;
const keyPrefix = @appgyverApp/${appId}/default/local-resource:${resourceName}:;

Works perfectly now.