18

I'm looking for a javascript library that will let me store data in a client side database and in the back ground automatically sync the database back to the server's database

preferable something that supports a variaty of engines in the same way jStore for jQuery does

Looking around I can find anything

Jonas
  • 121,568
  • 97
  • 310
  • 388
msaspence
  • 1,424
  • 2
  • 14
  • 25

9 Answers9

5

Just stumbled across this question; for posterity, CouchDB and CouchBase are designed for this:

http://couchdb.apache.org/

The JavaScript client:

https://pouchdb.com/

And CouchBase:

https://www.couchbase.com/

Finally, CouchBase Lite/Mobile:

https://www.couchbase.com/products/lite

The latter gets you native CouchDB/CouchBase synchronization.

In all cases you just access the local database and it can synchronize if and when you connect to the internet.

SomeCallMeTim
  • 4,503
  • 2
  • 28
  • 27
3

Store.js deal with the client-side storage very well. Note that it supports IE6+ along with other browsers. For the server-side storage you might as well make your own script for that as it should not be difficult.

jairajs89
  • 4,495
  • 3
  • 18
  • 14
  • 2
    According to their documentation: "store.js uses localStorage when available, and falls back on the userData behavior in IE6 and IE7". It does not store to Web SQL Database or IndexedDB. Also it does nothing for data synchronization. – Julien Kronegg May 03 '13 at 13:49
3

Since this question was asked, there's been a lot of work done on local storage and client side databases.

There's a great overview of local storage options at Dive Into HTML5.

There are also several cross-platform JavaScript storage libraries available, including Lawnchair and persistence.js.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Sam Dutton
  • 14,775
  • 6
  • 54
  • 64
1

Iam not 100% sure, but i think there isnt such a framework. I would recommend to have a look on Google Gears.

Google Gears supports offline storage on client side.

Another approach would be to check out the sourcecode of TidlyWiki. They have created an wiki system wich stores all data on client side.

opHASnoNAME
  • 20,224
  • 26
  • 98
  • 143
  • 1
    offline storage isn't so hard as it once was, there are some libraries that support either Gears, HTML5 local DB and flash. the original question is more about the background sync with the server (when online) – Javier Mar 14 '10 at 12:58
  • 1
    Also, Google Gears is being dropped. – Henrik Hansen Jul 28 '10 at 16:26
1

I'm not aware of any library that does that nowadays. Even tough this is a possible idea, I must say that I'm not sure if making such library is a good effort.

It would have to provide examples of how to expose your server data to the library, how to calculate deltas, and so on. This would force the developer to change this server side code accordingly to the library's protocol. This could be great for new apps and websites, but this could be a pain to any existing site, with particular data structure, making the effort to implement this not so much preferable to developing your own Javascript to do that with current data already exposed by the app. All of these on top of potential security problems would be kinda hard to manage in one generic javascript library.

IMHO this is a great idea to make bundles or plugins to specific ORM based MVC frameworks, for example Ruby on Rails or Django. Since the framework itself has an abstraction to the data structure and many security fixes already bundled together, making a bundle to do that would be much more re-usable and more elegant.

Irae Carvalho
  • 777
  • 1
  • 6
  • 19
0

Did you try jsonengine?

Not sure how much this project is alive but this answers all yor requirments.

Ronen
  • 807
  • 1
  • 13
  • 33
  • As far as I understood, `jsonengine` is an implementation of server-side RESTful API. It provides usage examples which either persist data to the server or to the client local storage. However, nothing is done for client-server synchronization. – Julien Kronegg May 03 '13 at 13:40
0

Firebase does this, although it is not a relational model

yazz.com
  • 57,320
  • 66
  • 234
  • 385
0

I've been doing some work on this. It seems to be almost possible using Google Documents. Most of the APIs are accessible via Javascript. Unfortunately the exceptions include things like upload and download, so while it's possible to enumerate documents, create files, change metadata etc all from inside the browser, actually getting at the data is a lot harder.

Google Spreadsheets do have Javascript APIs for accessing individual cells, so it's theoretically possible to store your data in a spreadsheet. Unfortunately there's another whole in the API where it seems to be rather hard to write data to a cell that previously did not have data in it, which means that once you've created your empty spreadsheet, you can't populate it...

David Given
  • 13,277
  • 9
  • 76
  • 123
0

As far as I know Safari, Chrome, and Opera all based on SQLite. SQLite has a .dump command which is not only great to restore a database but to sync with another database. Therefore, it may be possible to call this from the Javascript Database using .dump, and if necessary, modify the dump and upload it to the server database to execute.

However, you will want to be careful of SQL injection attempts.

Dougpan
  • 87
  • 4