如何在本机上访问本地数据库?

时间:2015-03-28 05:08:38

标签: react-native

我们经常在开发应用程序时访问本地sqlite数据库。反应原生的对应物是什么?我是否必须使用AsyncStorage来存储没有本机模块的数据?

4 个答案:

答案 0 :(得分:20)

更新的答案:现在有一个初出茅庐的SQLite包装器:

https://github.com/andpor/react-native-sqlite-storage

此前:

This comment on Hacker News表示现在没有可用的内容:

  

目前没有针对SQLite的本机模块,但您可以构建一个   如果你想。 :-D   http://facebook.github.io/react-native/docs/nativemodulesios.html

     

我们在大多数客户端持久性中使用键值存储:   http://facebook.github.io/react-native/docs/asyncstorage.html

Eric Vicenti似乎在Facebook工作并为React Native做出贡献,因此非常具有权威性。

答案 1 :(得分:14)

React Native的全功能SQLite插件可在此处获取:

https://github.com/andpor/react-native-sqlite-storage

版本2.1.0支持iOS和Android,而fmk同时具有普通的JS回调和基于Promise的接口。

答案 2 :(得分:12)

Realm React Native使您能够以安全,持久和快速的方式有效地编写应用程序的模型层。这是它的样子: 看到 Realm React NativeDocs For Realm

答案 3 :(得分:4)

用于react-native的嵌入式持久性或内存数据库 https://github.com/smartdemocracy/react-native-local-mongodb

它有性能统计

  • 插入:10,680 ops / s
  • 查找:43,490 ops / s
  • 更新:8,000 ops / s
  • 删除:11,750 ops / s