Domanda

I'm having trouble deleting my PouchDB to reset my jQuery Mobile app.

(Equivalent jsFiddle: http://jsfiddle.net/bYR8c/2/)

I have in app.js:

var db = new PouchDB('petrolog');

function resetDb(){
    db.destroy(function(err, info) { console.log('Error: ' + err); 
       console.log('Info: ' + info); }); //this is line 38, referenced in errors below
    showFillups(); //redraws the UI
}

and in index.html:

<head>
<script src="http://download.pouchdb.com/pouchdb-nightly.js"></script>
</head>

<body>
<a id="btnResetDb" class="ui-shadow ui-btn ui-corner-all">Erase all fillups</a>

<script> $('#btnResetDb').click(function(event){resetDb();}); </script>
</body>

When I click the button, I get the following from FireBug:

Error: null        app.js (line 38)
Info: undefined    app.js (line 38)

these correspond to my db.destroy() instruction in resetDb()

Any suggestions? I've already checked the API docs at http://pouchdb.com/api.html#delete_database but didn't find much help there.

È stato utile?

Soluzione

The destroy() method doesn't actually return anything for info. The fact that error is null indicates that everything was successful.

This is actually a bug in the documentation of PouchDB, which we'll fix.

FWIW, though, your jsfiddle doesn't work for unrelated reasons: the fiddle environment doesn't seem to have access to any local databases, so in Firefox I see Error: No valid adapter found.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top