Asoh Frank wrote:
I am new to non relational databases and couchdb as a whole. I want to ask if
there is any flexible possibility of comparing an existing document in the
couchdb database with another document(json file) not in the database then the
difference between them will be uploaded(updated) to the current existing
document ?
This could be achieved with a design document update function. Something
like:
function(doc, req) {
// doc is the destination doc id
// req.body contains the text representation of the JSON document
to merge
// e.g. curl -X POST
http://mycouch:5984/mydb/_design/merger/_update/merge/id-of-dest-doc -H
"Content-Type: application/json" -d @doc-to-merge.json
var jbody = JSON.parse(req.body);
try {
// my code to merge jbody on to doc
}
catch(e) {
return([null, "my error explanation"]);
}
return([doc, "OK"]);
}
James