0.0.1 • Published 9 years ago

websql-client v0.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

WebSQL Client

websql-server exposes a sqlite API originally defined at Cordova-SQLitePlugin through Websockets.

websql-client connects to websql-server and implements the WebSQL API.

Usage

Install websql-server:

npm install -g websql-server

Start websql-server:

websql-server

Import websql-client (a bower package) and primus in your html (Primus is automatically served by websql-server):

<script src="bower_components/websql-client/dist/websql-client.js"></script>
<script src="http://localhost:8082/primus/primus.js"></script>

Include the initialization code:

var db = window.sqlitePlugin.openDatabase({name: "my.db", location: 1});

A more advanced installation would conditionally load websql-client if a browser environment is detected, otherwise load Cordova-SQLitePlugin.

Testing

Running tests in the web browser

serve up the whole project as a static site with: http-server (npm package)

navigate to: http://localhost:8080/test/browser/tests/index.html

Intended Use cases

  • Testing and prototyping Cordova Apps in the web browser that use Cordova-SQLitePlugin.
  • Running unit tests for code that depends on a websql api (TODO: document how to set this up).

Advantages over using browser's Built in WebSQL implementations:

  • No limitations of current WebSQL implementations, such as:
  • Sqlite connection, initialization and query caching is retained when you refresh/reload your app. Your app only has to reconnect to the web server through Websockets. This allows for fast livereload incremental app development.