将本地HTML5 DB(WebSQL存储,SQLite)与服务器同步的最佳方式(双向同步) [英] Best way to synchronize local HTML5 DB (WebSQL Storage, SQLite) with a server (2 way sync)

查看:259
本文介绍了将本地HTML5 DB(WebSQL存储,SQLite)与服务器同步的最佳方式(双向同步)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为本地数据库(使用html5 webstorage)开发移动Web应用程序(用于iPhone和Android),因此当用户离线时,我的应用程序仍可用。



这很好用,但我想在服务器上保存本地数据。所以我需要将本地数据库与服务器上的数据库同步。同步只能是一种方式,但将来我希望以两种方式同步它(服务器本地数据库)。



这个需求看起来非常常见(或将在移动网络应用程序的未来常见),但我无法找到一个图书馆。



我知道谷歌正在这样做他们的移动网络应用程序(例如gmail),并且我找到了 WSPL项目一个谷歌项目,但没有下载源。



如果我找不到解决方案,我会创建一个库来做到这一点,因为一种方式同步看起来并不困难,但我不知道是否有其他解决方案。 解决方案


  • 我创建了一个名为 WebSqlSync 的小型JS库,以将本地WebSql DB与服务器(客户端 - > - 服务器)同步。非常易于使用并集成到您的代码中:


https://github.com/orbitaloop/WebSqlSync




  • 开源项目 QuickConnect 包含一个JS库,用于将本地HTML5 SQLite数据库同步到服务器数据库(MySQL或其他):


http://quickconnect.pbworks.com/Using-Enterprise-Synchronization



要使用这个库,您需要使用框架的DataAccessObject来访问您的数据库。它的工作原理是存储应用于数据库的所有SQL请求(当然除了选择),并将它们发送到服务器。管理删除非常好,但是如果你有很多更新,并且服务器需要使用相同的SQL语言,那么这有点重要......




  • 另一个来自 QuickConnect 的项目是原生SQLite同步(适用于iOS或Mac OS的Objective C和适用于Android的Java):
  • ul>

    http://www.quickconnectfamily.org/qcdbsync/
    (我认为它也存储了所有SQL请求的历史记录)




    • 我刚刚发现另一个有前途的JS库: persistenceJS



    https://github.com/zefhemel/persistencejs

    persistence.js是一个异步的Javascript对象关系你可以在浏览器和服务器上使用它(你可以在它们之间共享数据模型)。​​



    他们有一个DB同步模块: DOC的persistence.synch.js



    (适用于客户端上的HTML5数据库SQLite或Google Gears,以及服务器上的MySQL)


    • 还有 Impel.inTouch 。它看起来非常容易使用(包括php文件),但是您必须在客户端使用Mootools框架:
    • href =http://impel.simulacre.org/api/Impel.inTouch =noreferrer> http://impel.simulacre.org/api/Impel.inTouch




      • Sencha还有一个同步服务: Sencha.io 。看起来不错,但它依赖于Sencha Touch框架:



      http://www.sencha.com/products/io/


      I am developing a mobile web application (for iPhone & Android) with a local database (using html5 webstorage) so my app is still usable when the user is offline.

      This is working perfectly, but I want to save the local data on a server. So I need to synchronize the local DB with a DB on a server. The synchronisation can only be one way, but in the future, I would like to synchronize it in the both way (server <-> local DB).

      This requierement looks very common (or will be common in the future for mobile web app), but I can't find a library doing that.

      I know google is doing that in their mobile web app (ex. gmail), and I found the WSPL project a google project but without source to download.

      If I can't find a solution, I will create a library to do that, as one way sync doesn't look difficult, but I wonder if there are other solutions.

      解决方案

      • I created a small JS lib named WebSqlSync to synchronize a local WebSql DB with a server (client <-> server). Very easy to use and to integrate in your code :

      https://github.com/orbitaloop/WebSqlSync

      • The open source project QuickConnect contains a JS library to synchronize the local HTML5 SQLite DB to a server DB (MySQL or other) :

      http://quickconnect.pbworks.com/Using-Enterprise-Synchronization

      To use this lib, you need to use the DataAccessObject of the framework to access your DB. It works by storing all the SQL request applied to the DB (except select of course) , and sending them to the server. It's great to manage deletion, but it's a little heavy if you have a lot of updates, and the server need to use the same SQL language...

      • Another project from QuickConnect is a native SQLite synch (in Objective C for iOS or Mac OS and in Java for Android) :

      http://www.quickconnectfamily.org/qcdbsync/ (I think it store also the history of all the SQL requests)

      • And i just found another promising JS library : persistenceJS

      https://github.com/zefhemel/persistencejs

      "persistence.js is an asynchronous Javascript object-relational mapper library. You can use it in the browser, as well on the server (and you can share data models between them)."

      They have a DB synch module: DOC of persistence.synch.js

      (works with HTML5 DB SQLite or Google Gears on the client, and MySQL on the server)

      • And there is also Impel.inTouch. It looks very easy to use (with php files included), but you must use the Mootools framework in the client side :

      http://impel.simulacre.org/api/Impel.inTouch

      • Sencha has also a synchronisation service: Sencha.io. Looks great, but it's dependent of the Sencha Touch framework:

      http://www.sencha.com/products/io/

      这篇关于将本地HTML5 DB(WebSQL存储,SQLite)与服务器同步的最佳方式(双向同步)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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