var db, | |
callback = function(err,database){ | |
if(err){ | |
console.error("Bad Stuff happend"); | |
}else{ | |
console.log("good news!") | |
db=database; | |
} | |
}; | |
var makePouch = function(url,cb){ | |
var rep; | |
if(url.slice(-1)==="/"){ | |
url = url.slice(0,-1); | |
} | |
var dbName = url.split("/").pop(); | |
Pouch(dbName, function(err1,db1){ | |
if (err1) { | |
Pouch(url,function(err2,db2){ | |
if (err2) { | |
cb(err2); | |
} else { | |
cb(null,db2) | |
} | |
}); | |
} else { | |
rep = function(err3){ | |
if (err3) { | |
console.error(err3); | |
} | |
}; | |
Pouch.replicate(dbName, url, {continuous: true}, rep); | |
Pouch.replicate(url, dbName, {continuous: true}, rep); | |
cb(null, db1); | |
} | |
}); | |
}; | |
makePouch("http://url.to.couchdb/dbname",callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment