Skip to content

Instantly share code, notes, and snippets.

Avatar

Marten de Vries marten-de-vries

View GitHub Profile
View pouchdb-promisify.js
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 Sep 10, 2020
Running CouchApps on PouchDB in the browser using service workers - without any modifications!
View README.md

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 Jan 28, 2015
Resurrecting the .destroy() function
View example.js
//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 Aug 29, 2015
evaljs mapreduce - testing the new API
View README.md

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 Jan 9, 2015
Trying to reproduce Travis failure.
View gist:bd0013875b5e53675f56
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 Dec 21, 2014
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.
View api.pot
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
pouchdb-mapreduce tests with coverage for the PR #179 code.
View gist:e67fc8415dbe85bdab41
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