Created
January 14, 2017 21:10
-
-
Save JeffML/3bd21b3f1fba0bc37228fb93d22333a2 to your computer and use it in GitHub Desktop.
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
const PouchDB = require('pouchdb'); | |
const db = new PouchDB('choices'); | |
// doc that defines the view | |
var ddoc = { | |
_id: '_design/choice', | |
views: { | |
by_key: { | |
map: function (doc) { | |
emit(doc.key, doc.taste); | |
}.toString() | |
} | |
} | |
}; | |
// remove any existing view, then add new one: | |
db.get(ddoc._id) | |
.then(doc => { | |
return db.remove(doc); | |
}) | |
.then(() => { | |
db.put(ddoc) | |
.catch(function (err) { | |
console.error(err); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment