I have the problem that I like to "automagically" delete documents in my couch, which are at least 6 month old. My CouchDb instance runs on a linux server, is there any way to achieve this quite simple (like writing a simple 2-line shell script) ?
You can write an update function in couchdb that deletes a doc on certain criteria ( you can use params while calling the function) : http://wiki.apache.org/couchdb/Document_Update_Handlers#Creating_an_Update_Handler
(look at "in-place" and imagine setting "_delete:true").
something like
"deletefunc":
...
if(doc.created_at<req.query.mindate) {
doc._deleted:true;
return [doc, "deleted"]
}
and calling ...db/_design/updatefuncdesigndoc/_update/deletefunc/dok_id_x?mindate=20110816
The only work is: calling each doc in a database explicit with this function (calling _all_docs or _changes first)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With