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:
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:
What tools can solve this problem?
解决方案
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
also if you use redux you can also use redux-persist