-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PouchDB on Phonegap
Nolan Lawson edited this page Feb 25, 2015
·
8 revisions
PouchDB will try to detect if it's in a Cordova/Phonegap instance. However, you must create and use PouchDB inside an onDeviceReady()
function, especially if you are using the SQLite Plugin, because PouchDB can only detect the SQLite Plugin after the deviceready
event.
Here's an example of PouchDB usage in Phonegap:
var db;
function onDeviceReady() {
db = new PouchDB("helloworld");
// okay, now we have our database
}
// The below, or something like it, is necessary
// to use PouchDB functionality!
document.addEventListener("deviceready", onDeviceReady, false);
If you get stuck, there is a tutorial with sample apps available at pouchdb-phonegap-cordova. You may also want to check out pouchdb-ionic.