var PouchDB = require('pouchdb'); var plugin = require('./index'); PouchDB.plugin(plugin); var db = new PouchDB('test', {db: require('memdown')}); db.bulkDocs([ { _id: '_design/test', views: { test: { map: function (doc) { // a relatively 'complicated' view for (var i = 0; i < doc.roles.length; i++) { var role = doc.roles[i]; if (role.indexOf('a') === -1) { emit(role); } } }.toString() } } }, { roles: ['b', 'c', 'a'] }, { roles: ['e', 'f', 'b'] } ]).then(function () { return db.evaljsQuery('test/test'); }).then(function (resp) { console.log(resp.rows.map(function (item) { return item.key; // [ 'b', 'b', 'c', 'e', 'f' ] })); });