I'm new to react native and I need a list of local database tools that will meet the minimum criteria in the description to follow.
If this were a PHP/MySQL application, I build 3 database tables:
t_food (500 rows)
- food_id (primary_key)
- food_name (string)
t_meal (100 000 rows)
- meal_id (primary_key)
- meal_name (string)
t_meal_item (1 000 000 rows)
- meal_id (foreign_key)
- food_id (foreign_key)
These three tables combined in MySQL takes up about 10MB to 15MB. Then I would use PHP to create an interface that will present the results of this query:
SELECT meal_id FROM t_meal_item WHERE food_id = @food1 AND meal_id IN (SELECT meal_id FROM t_meal_item WHERE food_id = @food2 AND meal_id IN (SELECT meal_id FROM t_meal_item WHERE food_id = @food3))
In a MySQL/PHP application, the results of the SQL query will return in less than 2 seconds.
In the react-native world, I need a local database that achieves similar results to above but must also comply with the following requirements:
must support 15 MB of persistent storage (so that you can use it without internet access)
querying for a meal filtered by 3 food items must complete in less than 3 seconds on modern mainstream mobile devices. Eg. the equivalent of the SQL query above must complete in less than 3 seconds on an iphone 6 and Huawei Nova Plus.
I have already tried the following:
A. Realm is failing on criteria 2 as indicated in this question here:
Improve the speed of a realm query in react-native?
A solution to the Realm question will be an acceptable answer to this question.
B. Six years ago, I tried this with core data on an iOS device. The iOS device kept crashing due to insufficient memory.
C. I'm trying SQLite Storage but already running into this problem here:
basic React Native SQLite script returning undefined which causes error
What tools can solve this problem?
Async storage is a react native local storage database system that gives developers the capability to store data locally and persist data between the app reboots. The database comes in-built with React native so it can be used without any additional deployment.
Firebase. Firebase is one of the most popular BaaS platforms and yet another suitable backend option for React Native. It works great for mobile and web apps.
Firebase Firebase is owned by Google and supports a NoSQL database. It can manage MVC-based react native apps that require a high database. And if you want to develop an app that requires offline updation of data and synchronization, Firebase is the ideal choice.
consider react native as front end library thats need a restful api to connect so you can make backend with php and react native will receive data from it
if you need local database you can use react-native-local-mongodb
or react-native-sqlite-storage
or react-native-sqlite
also if you use redux you can also use redux-persist
I have not used those other databases that people listed, but I would recommend Realm. Very useful, fast, fully integrated with react-native and very well documented.
https://realm.io
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With