forked from storesafe/cordova-sqlite-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher J. Brody
committed
Feb 7, 2016
1 parent
ab81860
commit 1246edf
Showing
7 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ I raised [Cordova bug CB-9830](https://issues.apache.org/jira/browse/CB-9830) to | |
|
||
## Announcements | ||
|
||
- Added echo test function to verify installation of this plugin | ||
- All iOS operations are now using background processing (reported to resolve intermittent problems with [email protected]) | ||
- Published [brodybits / Cordova-quick-start-checklist](https://github.com/brodybits/Cordova-quick-start-checklist) and [brodybits / Cordova-troubleshooting-guide](https://github.com/brodybits/Cordova-troubleshooting-guide) | ||
- A version with support for web workers is available (with a different licensing scheme) at: [litehelpers / cordova-sqlite-workers-evfree](https://github.com/litehelpers/cordova-sqlite-workers-evfree) | ||
|
@@ -203,6 +204,18 @@ naelA/nativescript-sqlite) (Android and/or iOS) | |
|
||
# Usage | ||
|
||
## Echo test | ||
|
||
To verify that both the Javascript and native part of this plugin are installed in your application: | ||
|
||
```js | ||
window.sqlitePlugin.echoTest(successCallback, errorCallback); | ||
``` | ||
|
||
**IMPORTANT:** Please wait for the 'deviceready' event, (see below for an example). | ||
|
||
## General | ||
|
||
The idea is to emulate the HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/) as closely as possible. The only major change is to use `window.sqlitePlugin.openDatabase()` (or `sqlitePlugin.openDatabase()`) instead of `window.openDatabase()`. If you see any other major change please report it, it is probably a bug. | ||
|
||
**NOTE:** If a sqlite statement in a transaction fails with an error, the error handler *must* return `false` in order to recover the transaction. This is correct according to the HTML5/[Web SQL API](http://www.w3.org/TR/webdatabase/) standard. This is different from the WebKit implementation of Web SQL in Android and iOS which recovers the transaction if a sql error hander returns a non-`true` value. | ||
|
@@ -655,7 +668,13 @@ Sample change to `config.xml` for Cordova/PhoneGap 2.x: | |
<plugin name="Compass" value="CDVLocation" /> | ||
``` | ||
|
||
## Quick installation test | ||
## Installation test | ||
|
||
### Easy installation test | ||
|
||
Use `window.sqlitePlugin.echoTest` as described above (please wait for the `deviceready` event). | ||
|
||
### Quick installation test | ||
|
||
Assuming your app has a recent template as used by the Cordova create script, add the following code to the `onDeviceReady` function, after `app.receivedEvent('deviceready');`: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 'use strict'; */ | ||
|
||
var MYTIMEOUT = 12000; | ||
|
||
// simple tests: | ||
var mytests = function() { | ||
|
||
describe('SELF test(s)', function() { | ||
|
||
describe('ECHO test(s)', function() { | ||
it('Simple echo test', | ||
function(done) { | ||
window.sqlitePlugin.echoTest(function() { | ||
// ok: | ||
expect(true).toBe(true); | ||
done(); | ||
}, function(err) { | ||
// went wrong: | ||
expect(false).toBe(true); | ||
done(); | ||
}); | ||
}, MYTIMEOUT); | ||
}); | ||
|
||
}); | ||
|
||
}; | ||
|
||
if (window.hasBrowser) mytests(); | ||
else exports.defineAutoTests = mytests; | ||
|
||
/* vim: set expandtab : */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters