Skip to content

Instantly share code, notes, and snippets.

View marten-de-vries's full-sized avatar

Marten de Vries marten-de-vries

View GitHub Profile
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);
@marten-de-vries
marten-de-vries / README.md
Last active June 27, 2024 13:57
Running CouchApps on PouchDB in the browser using service workers - without any modifications!

Running CouchApps on PouchDB in the browser using service workers

What is this?

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.

Demo

@marten-de-vries
marten-de-vries / example.js
Created January 28, 2015 20:58
Resurrecting the .destroy() function
//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) {
@marten-de-vries
marten-de-vries / README.md
Last active August 29, 2015 14:13
evaljs mapreduce - testing the new API

How to run

  1. Get index.js and test.js in the same (otherwise empty) directory.
  2. Execute the following commands:
npm install pouchdb memdown pouchdb-abstract-mapreduce evaljs
node test.js
@marten-de-vries
marten-de-vries / gist:bd0013875b5e53675f56
Created January 9, 2015 12:33
Trying to reproduce Travis failure.
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
@marten-de-vries
marten-de-vries / api.pot
Created December 21, 2014 14:34
A base for a node js jekyll gettext preprocessor - requires docs/nl to exist and expects the first user visible string in api.md to be wrapped in a {%t %} tag.
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 ""
@marten-de-vries
marten-de-vries / gist:e67fc8415dbe85bdab41
Created May 31, 2014 13:31
pouchdb-mapreduce tests with coverage for the PR #179 code.
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