Created
January 28, 2015 20:58
-
-
Save marten-de-vries/d4d1f202d051aa31b87c to your computer and use it in GitHub Desktop.
Resurrecting the .destroy() function
This file contains hidden or 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
//PouchDB.destroy() is (going to be) deprecated by PouchDB, but the | |
//semantics from db.destroy() differ when wrapped so re-add it. | |
if (!(PouchDB.destroy || {}).isResurrected) { | |
var orig = PouchDB.destroy; | |
PouchDB.destroy = function (name, options, callback) { | |
var args = parseBaseArgs(PouchDB, this, options, callback); | |
//3.2.2 deprecates .destroy() and introduces opts.internal for as | |
//long as PouchDB will still use the method internally (hopefully) | |
if (!(PouchDB.version >= '3.2.2') || args.options.internal) { | |
return orig.apply(this, arguments); | |
} | |
var db = new PouchDB(name, args.options); | |
var promise = db.destroy(); | |
nodify(promise, args.callback); | |
return promise; | |
} | |
PouchDB.destroy.isResurrected = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment