Skip to content

Instantly share code, notes, and snippets.

@jchris
Created April 22, 2014 16:32
Show Gist options
  • Save jchris/11185782 to your computer and use it in GitHub Desktop.
Save jchris/11185782 to your computer and use it in GitHub Desktop.
var coax = require("coax"),
server = coax("https://localhost:59840/"),
database = server("tmp-test");
database.put(function(err, ok){
console.log("create db", err, ok)
var ddocID = "_design/foo"
database(ddocID, function(err, ddoc){
if (err) {
ddoc = {}
}
ddoc.views = {
myView : {
map : function(doc) {
emit(doc.mykey)
}
}
}
database.put(ddocID, ddoc, function(err, ok) {
console.log("ddoc save", err, ok)
var views = database("_view");
views.get(["myView",{include_docs : true}], function(err, data){
console.log("view",err,data.rows)
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment