I want to synchronize data from a nosql database, have it emit json, and when there is a change and the app is online, have the app pull the changes and update them.
My react-native app uses a few language-specific json files loading them dynamically into javascript objects and then using them as my "database". One file for rendering content, one for the app texts, and one for the styles.
When the user changes the language a different directory is used with the same set of json filenames. This is done via the index.js in that directory and loaded into redux.
Must I change the way my app works, and use a NoSQL/real database directly in the app? So that I can use a solution like this one: synchronizing pouchDB with json data
(that solution is for working if I understand correctly in the exact opposite direction. The app is working with a database and synchronizing with json received from the web)
Or can I update the data in an external (preferably) NoSQL (pouchDB or couchDB) or relational database, and somehow "synchronize" it with the json files, when the app is connected to the web and have it update?
Is there a known method or framework to accomplish this with react-native?
Related
I'm currently thinking of a concept for a react-native app where people add events over a period of time like a diary/log. These events need to be exported and for security and privacy reasons I don't want to use a database. I've read you can use JSON files as a storage method, too.
How can I store data from the app to a JSON file and load the data from the JSON file back in the app? Don't need any code, helpful articles or webpages are appreciated
Assuming that you already have all the app data into a json, its rather simple.
Decide where to store the appdata.json, lets call it APP_DATA_PATH
Find a library to read/write files (I've only used expo-file-system)
On app boot, check if APP_DATA_PATH exists, if it does read the file and load into app, if not assume its a new user
Whenever app data changes, write the changes to APP_DATA_PATH
I'm trying to make a centralized POS system, was wondering what are my options to save data locally to the device to save data connection rather than making the POS online-only app.
I already have the APIs from Laravel being pulled into JSON and basically need to find a way to store data, as well as to convert image_location into blob or something Flutter can do, (is Image.memory viable?). The APIs will only be triggered on app startup if the device is connected to the internet.
You can use a plugin called sqflite which works for ios and android.
and also SharedPreference plugin which stores data in key-value format.
you can search for plugins and there example on https://pub.dev/
I’m using react native, redux and firebase and I have a 1 MB database export that contains food nutritional information from the Canadian Nutrition File database.
This data will never change and is used in a FlatList users can search and import from.
What’s the optimal way for me to store this for my users to access as fast as possible when searching?
I am thinking of simply including the json file with my other source files and calling it from there using require.
But since I have firebase and redux all setup I wondered if it made more sense for whatever reason to consider those options instead.
Thanks in advance for any input.
Since you are already using redux, i'd go for adding the json content to the store on app init/mount so you can get it easily from everywhere.
Another options i'd consider:
Import, parse & render the JSON file stactically on runtime (as it never changes);
Use the AsyncStorage to make it available in local database but outsite the redux store thing.
I'm developing an Electron app that is running an instance React VR. The app enables a user to add and save content to a react-vr project by reading and writing the state from/to a JSON file. During development, this JSON file has been stored in the root directory. However, if a user is to download and use the app on their computer, the JSON file needs to be moved outside the app package contents folder.
I have tried using app.getpath('userdata') which returns /Users/'username'/Library/Application Support/'app_name', and I can move the JSON state file there successfully upon running the app. However, I don't know how to have react-vr access this file, especially since there is no access to the computer's file system. However, all I really need is the user's system username to include in the 'userdata' file path.
What's the best way to go about retrieving the username from within react-vr? Would there be a better way to persist user data instead of a using a JSON file to keep track of the state? Would it be worth considering using AsyncStorage in conjunction with a database? Many thanks.
I have a number of different types of files stored in a MySQL database (varbinaryMAX). I am in the process of building a document management system and my final phase is to install some sort of document viewer so that these files can be prievewed.
I have veered away from Google Docs due to the security of the documents. I have [preliminarily] settled with Viewer.JS as my chosen method of preview as it supports a wide variety of filetypes, and is free. It does however require a directly accessible URL for the file, which I of course dont have as the file is sitting in a coloumn in the DB.
How would I go about generating a URL that can be used to access a/the file in the DB?
Application is ASP.net