我在React Native上使用什么本地数据库? [英] What local database do I use with React Native?
问题描述
我是本机的新手,我需要一个满足以下说明中最低标准的本地数据库工具列表。
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.
如果这是一个PHP / MySQL应用程序,我建立了3个数据库表:
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)
这三个表在MySQL中的组合占用了大约10MB到15MB的空间。然后,我将使用PHP创建一个界面,该界面将显示此查询的结果:
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))
在MySQL / PHP应用程序中,SQL查询的结果将在不到2秒的时间内返回。
In a MySQL/PHP application, the results of the SQL query will return in less than 2 seconds.
在react-native世界中,我需要一个与上述结果相似的本地数据库,但还必须符合以下要求:
In the react-native world, I need a local database that achieves similar results to above but must also comply with the following requirements:
-
必须支持15 MB持久存储的数量(这样您就可以在不访问互联网的情况下使用它)
must support 15 MB of persistent storage (so that you can use it without internet access)
查询由3种食品过滤的餐点,在现代系统中必须在不到3秒内完成主流移动设备。例如。在iPhone 6和Huawei Nova Plus上,相当于上面的SQL查询必须在不到3秒的时间内完成。
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。领域在此问题所指示的条件2上失败:
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。六年前,我在iOS设备上使用核心数据进行了尝试。由于内存不足,iOS设备不断崩溃。
B. Six years ago, I tried this with core data on an iOS device. The iOS device kept crashing due to insufficient memory.
C。我正在尝试使用SQLite Storage,但在这里已经遇到了这个问题:
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?
推荐答案
考虑将本机作为前端库,需要一个安静的api进行连接,以便可以使用php和react native将从中接收数据
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
如果您需要本地数据库,则可以使用 react-native-local-mongodb
if you need local database you can use react-native-local-mongodb
如果您使用 redux ,您也可以使用 redux-persist
also if you use redux you can also use redux-persist
这篇关于我在React Native上使用什么本地数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!