Comparing version 0.1.0 to 0.2.0
'use strict'; | ||
var sqlite3 = require('sqlite3'); | ||
var immediate = require('immediate'); | ||
var argsarray = require('argsarray'); | ||
var noop = require('noop-fn'); | ||
var customOpenDatabase = require('./custom'); | ||
var WebSQLDatabase = require('./WebSQLDatabase'); | ||
function createDb(dbName, dbVersion) { | ||
var sqliteDatabase = new sqlite3.Database(dbName); | ||
return new WebSQLDatabase(dbVersion, sqliteDatabase); | ||
} | ||
function openDatabase(args) { | ||
if (args.length < 4) { | ||
throw new Error('Failed to execute \'openDatabase\': ' + | ||
'4 arguments required, but only ' + args.length + ' present'); | ||
} | ||
var dbName = args[0]; | ||
var dbVersion = args[1]; | ||
// db description and size are ignored | ||
var callback = args[4] || noop; | ||
var db = createDb(dbName, dbVersion); | ||
immediate(function () { | ||
callback(db); | ||
}); | ||
return db; | ||
} | ||
module.exports = argsarray(openDatabase); | ||
module.exports = customOpenDatabase(sqlite3); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
function onTransactionComplete(err) { | ||
self._db.run('END TRANSACTION;', function () { | ||
self._db.run('END TRANSACTION;', [], function () { | ||
self._running = false; | ||
@@ -14,0 +14,0 @@ |
{ | ||
"name": "websql", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "WebSQL Database API, implemented for Node using sqlite3", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -1,5 +0,5 @@ | ||
node-websql [![Build Status](https://travis-ci.org/nolanlawson/node-websql.svg?branch=master)](https://travis-ci.org/nolanlawson/node-websql) [![Coverage Status](https://coveralls.io/repos/github/nolanlawson/node-websql/badge.svg?branch=master)](https://coveralls.io/github/nolanlawson/node-websql?branch=master) | ||
node-websql [![Build Status](https://travis-ci.org/nolanlawson/node-websql.svg?branch=master)](https://travis-ci.org/nolanlawson/node-websql) [![Coverage Status](https://coveralls.io/repos/github/nolanlawson/node-websql/badge.svg?branch=master&nonce=foo)](https://coveralls.io/github/nolanlawson/node-websql?branch=master) | ||
==== | ||
The [Web SQL Database API][websql], implemented for Node | ||
The [WebSQL Database API][websql], implemented for Node | ||
using [sqlite3](https://github.com/mapbox/node-sqlite3). | ||
@@ -43,3 +43,3 @@ | ||
The `callback` just returns the same database object returned | ||
The `callback` just returns the same database object returned | ||
synchronously (_migrations currently aren't supported - see below_). | ||
@@ -52,6 +52,19 @@ | ||
### Custom sqlite3 implementation | ||
If you'd like to use your own `sqlite3` implementation, just do: | ||
```js | ||
var customOpenDatabase = require('websql/custom'); | ||
var openDatabase = customOpenDatabase(mySqlite3); | ||
``` | ||
Your responsibility as a developer is to implement the subset of the | ||
`sqlite3` API which this module uses. At this time, that means the `db.all()` | ||
and `db.run()` methods. See the [sqlite3 docs](https://github.com/mapbox/node-sqlite3) for more info. | ||
Goals | ||
---- | ||
The [Web SQL Database API][websql] is a deprecated | ||
The [WebSQL Database API][websql] is a deprecated | ||
standard, but in many cases it's useful to reuse legacy code | ||
@@ -83,4 +96,4 @@ designed for browsers that support WebSQL. Also, it allows you to quickly | ||
The versioning and migration APIs | ||
(i.e. [`changeVersion()`](https://www.w3.org/TR/webdatabase/#dom-database-changeversion)) | ||
The versioning and migration APIs | ||
(i.e. [`changeVersion()`](https://www.w3.org/TR/webdatabase/#dom-database-changeversion)) | ||
are not supported. Pull requests welcome! | ||
@@ -110,3 +123,3 @@ | ||
npm run test-local | ||
Run the actual-WebSQL test against PhantomJS: | ||
@@ -113,0 +126,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25271
8
270
127