A description of how to run an existing CouchApp on PouchDB in the browser using service workers - without any modifications to existing code being necessary! The best thing is that if service workers aren't available, the CouchApp will still run as normal: that is, online.
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
var wrappers = require("pouchdb-wrappers"); | |
var noops = {}; | |
// also add all the other methods | |
"get allDocs getAttachment info revsDiff put post".split(" ")).forEach(function (name) { | |
noops[name] = function (orig) {return orig(); }; | |
}); | |
wrappers.installWrapperMethods(db, noops); |
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
//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) { |
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
marten@procyon:~/Bureaublad$ mkdir temp | |
marten@procyon:~/Bureaublad$ cd temp/ | |
marten@procyon:~/Bureaublad/temp$ npm cache clean | |
marten@procyon:~/Bureaublad/temp$ git clone --depth=30 git://github.com/pouchdb/express-pouchdb.git pouchdb/express-pouchdb | |
marten@procyon:~/Bureaublad/temp$ cd pouchdb/express-pouchdb | |
marten@procyon:~/Bureaublad/temp/pouchdb/express-pouchdb$ git fetch origin +refs/pull/170/merge: | |
marten@procyon:~/Bureaublad/temp/pouchdb/express-pouchdb$ git checkout -qf FETCH_HEAD | |
marten@procyon:~/Bureaublad/temp/pouchdb/express-pouchdb$ export CLIENT=node | |
marten@procyon:~/Bureaublad/temp/pouchdb/express-pouchdb$ export COMMAND=test-pouchdb-minimum | |
marten@procyon:~/Bureaublad/temp/pouchdb/express-pouchdb$ npm install |
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
msgid "" | |
msgstr "" | |
msgid "Most of the PouchDB API is exposed as `fun(arg, [options], [callback])` where both the options and the callback are optional. Callbacks use the `function(err, result)` idiom where the first argument will be undefined unless there is an error, and the second argument holds the result." | |
msgstr "" |
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
marten@marten-laptop:~/git/mapreduce$ npm run test --coverage | |
> pouchdb-mapreduce@2.2.3 test /home/marten/git/mapreduce | |
> npm run jshint && ./bin/run-test.sh | |
> pouchdb-mapreduce@2.2.3 jshint /home/marten/git/mapreduce | |
> jshint -c .jshintrc *.js test/test.js | |