How to download data and save it as offline data source (Json file or other)

I’m just starting to study Fuse to build my first app. The app should lists the events in my town. The events are now stored in a mySQL db. As I would like that the app worked offline too, I was thinking about doing the following:

  1. A CronJob exports the mySQL db into a JSON file
  2. When the user launches the app it checks if there’s a new version on the JSON file on the server
  3. If there’s a new version the app downloads the file and it saves it into a folder in the device
  4. The app deletes any old version of the JSON file and it loads and display the content of the new JSON file

Do you think this approch has sense? Can Fuse download, store and delete files?

I know that Fuse supports JSON but if you think that this approach is not efficient or convenient what could be a better solution to have a offline data source? If Fuse supports SQLite (can’t find about it in the documentation) should I then use SQLite?

Thank you.

Hi!

You can use the Fetch function to download your json file, and then use Storage to save the downloaded file to storage.

JSON.stringify() and JSON.parse() might also be of interest.

If you want to use SQLite rather than JSON, a community member called Bolav made a package that allows you to use SQLite in fuse, which you can check out here.