Ionic PouchDb Sqlite插件问题 [英] Ionic PouchDb Sqlite plugin issue

查看:294
本文介绍了Ionic PouchDb Sqlite插件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在认真地探索Ionic,PouchDb和CouchDb作为我们的需求之一的解决方案,我们需要构建一个移动应用程序,它可以提供离线同步功能,也是平台无关。

We are seriously exploring Ionic, PouchDb and CouchDb as a solution to one of our requirement where we need to build a mobile app which can provide offline sync functionality and also to be platform agnostic.

我们拥有的其他主要需求之一是,离线模式下的数据将是持久性的,并且可以增长超过500 MB,因为PouchDb将使用IndexedDB / WebSQL适配器等以离线模式存储数据,它在移动和Web平台中具有一定的大小限制,并且数据本质上不是持久性的。

One of the other major requirement we have, that the data in offline mode would be persistence in nature and can grew more than 500 MB and since PouchDb is going to use IndexedDB / WebSQL adapters etc. to store data in offline mode, it has certain size limitation in mobile and web platform and also the data is not persistence in nature.

在pouchdb网站本身的此文章:

Then I came across this article in pouchdb site itself:


http://pouchdb.com/adapters.html

您可以在Cordova中使用SQLite插件你可以这样写:

Where you can use SQLite plugin for Cordova and you can write something like:

强制PouchDb使用SQLite插件。

To force the PouchDb to use SQLite plugin.

var db = new PouchDB('myDB', {adapter: 'websql'});

但是当我测试代码使用下面的代码来检查WebSql适配器是否使用SQLite插件, (chrome远程调试)和web平台。

But when I test the code using following code to check whether WebSql adapter is using SQLite plugin or not, both in Android (chrome remote debugging) and web platform.

db.info().then(console.log.bind(console));

sqlite_plugin总是返回false,也不是创建任何.db文件。虽然PouchDb和CouchDb同步工作正常。

The sqlite_plugin is always returning false and also it is not creating any .db files. Though PouchDb and CouchDb sync is working fine.

Object {doc_count: 5, update_seq: 42, sqlite_plugin: false, websql_encoding: "UTF-8", db_name: "birthdays"…}
1.  adapter: "websql"
2.  auto_compaction: false
3.  db_name: "testDb"
4.  doc_count: 5
5.  sqlite_plugin: false
6.  update_seq: 42
7.  websql_encoding: "UTF-8"
8.  __proto__: Object
And also it mentioned




SQLite插件目前不传递PouchDB测试套件。它
也往往比直接IndexedDB / WebSQL慢。我们建议
避免使用SQLite插件,除非您在iOS中击中50MB存储
限制,或者您需要对数据库
文件进行本机或预装访问。

The SQLite Plugin does not currently pass the PouchDB test suite. It also tends to be slower than direct IndexedDB/WebSQL. We recommend avoiding the SQLite Plugin, unless you are hitting the 50MB storage limit in iOS or you require native or preloaded access to the database files.

我使用以下命令安装SQLite插件:

I have used following command to install the SQLite plugin:

cordova plugin add https://github.com/brodysoft/Cordova-SQLitePlugin.git

这里是Ionic版本信息:
点击查看我目前使用的Ionic版本信息。

Here is Ionic version information: Click to see the Ionic version information currently using by me.

PouchDB版本:5.2.0

PouchDB version: 5.2.0

如果有人能帮助我解决这个问题,先感谢。

I would highly appreciate if someone can help me to solve this issue. Thanks in advance.

推荐答案

有一个演示使用PouchDB和SQLite插件的Cordova应用程序。很可能你只需要确保在PouchDB < script> 之前加载SQLite插件< script>

There is a demo of a Cordova app using PouchDB and the SQLite Plugin. Mostly likely you just need to make sure that SQLite Plugin <script> is loaded before the PouchDB <script>.

也就是说,如果你的应用数据严重500MB(半GB!),我建议不要使用PouchDB。特别是如果你不使用同步,那么PouchDB的修订结构开销太大,运行缓慢。

That said, if your app data is seriously 500MB (half a GB!), I would recommend against using PouchDB. Especially if you are not using sync, then PouchDB has too much overhead with the revision structure and will run slowly.

你可能最好直接使用SQLite插件。希望有所帮助!

You are probably better off directly using the SQLite Plugin. Hope that helps!

这篇关于Ionic PouchDb Sqlite插件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆