用于Cordova / PhoneGap的PouchDB + SQLite插件

时间:2014-10-24 01:54:28

标签: cordova android-sqlite firebase pouchdb

我尝试创建网络应用程序以及移动应用程序(使用 PhoneGap )。我使用HTML5 / CSS / JS,因为我必须与PhoneGap兼容。我需要我的移动应用程序才能使用脱机工作(我应该能够至少将数据推送到数据库,不太关心检索它,可以限制用户上线获取数据)。我知道它有点奇怪,但这就是我的要求。

  • 我尝试使用 Firebase ,在开发过程中我明白它并不是真正的执着!它只能处理网络中断等,但不会在PhoneGap App会话之间保留数据。 [我的理解即使用 AngularFire 也不可能]

我以某种方式登陆 PouchDB 。在编译PhoneGap应用程序时,它似乎可以像我一样使用 SQLite插件。正如这里所讨论的:http://pouchdb.com/adapters.html(Cordova / PhoneGap的SQLite插件) - 我知道它可以无缝脱机工作,并在线时与PhouchDB同步,而无需任何开发人员干预。

我不想再浪费时间而只是盲目地使用PouchDB。我想在探索它之前确认它的功能。

  1. 我对PouchDB的假设是否正确?
  2. 这是否可以在本地和本地之间进行无缝通信在线数据库服务器?
  3. 对我来说还有其他更好的选择吗?
  4. 注意:每次写入数据库时​​,我的数据都将是普通文本以及单个图像。 (我需要存储图片 - 在某个地方,也应该很容易在线和离线 - 欢迎任何建议在这里欢迎)

    谢谢&的问候,

    inblueswithu

2 个答案:

答案 0 :(得分:5)

我发现这篇文章大约10个月,因为我和OP一样,从Firebase开始,想要脱机。我现在已经在Ionic / Cordova上使用PouchDB,CouchDB进行编码,它100%是您梦寐以求的。

PouchDB是"只是"适用于大多数存储引擎的CouchDB API(WebSql,Sqlite,IndexedDB,Level等)。最好的API还支持与其他CouchDB同步。

最重要的是学习如何利用CouchDB的_id以及它们的全部价值。

答案 1 :(得分:1)

I believe that Firebase has local (offline) persistence capabilities but only when you use the native Android or iOS SDKs, apparently it's not there in the Javascript SDK yet.

For my app this doesn't really matter because I think my app is pretty useless without a network connection anyway. So why bother adding more complexity to make it work 'offline'.

However if you do want offline capabilities then apart from the PouchDB/CouchDB combo (which I've heard about also) an interesting option might be Meteor (to be precise the angular-meteor project):

http://angular-meteor.com/

Apparently this gives you the same 'real-time' capabilities as Firebase:

www.codementor.io/meteor/tutorial/why-you-should-use-angular-meteor-library

And apparently you can make it work "offline" as well:

http://rafaelquintanilha.com/offline-app-with-meteor-and-cordova/