【问题标题】:How can I access local database on react native?如何访问本地数据库?
【发布时间】:2015-06-01 13:28:08
【问题描述】:

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

【问题讨论】:

    标签: react-native


    【解决方案1】:

    更新的答案:现在有一个新兴的 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 做出贡献,非常权威。

    【讨论】:

    【解决方案2】:

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

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

    2.1.0 版同时支持 iOS 和 Android,并且 fmk 具有纯 JS 回调和基于 Promise 的接口。

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

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

        它有性能统计数据

        • 插入:10,680 ops/s
        • 发现:43,290 ops/s
        • 更新:8,000 ops/s
        • 移除:11,750 ops/s

        【讨论】:

        • 如果要存储的数据是关系型,请注意选择 NoSQL 数据库。
        猜你喜欢
        • 1970-01-01
        • 2019-11-21
        • 2012-05-23
        • 1970-01-01
        • 2017-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-12
        相关资源
        最近更新 更多