incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Rakotojaona <matthieu.rakotoja...@gmail.com>
Subject Re: auto delete docs
Date Thu, 30 Aug 2012 16:05:45 GMT
On Thu, Aug 30, 2012 at 5:44 PM, Stephan Bardubitzki
<stephan@bardubitzki.com> wrote:
> I have a db with docs that have a field expire_date. I want to auto delete
> those docs when expire_date has passed, but have no clue how to do that.
>
> Any advise would be greatly appreciated.
>
> Thanks,
> Stephan

I don't think there is an internal way in CouchDB to do this.

I did my own approach here, a long time ago :
https://github.com/rakoo/MultiBin-burner. It's in erlang though.

Basically, you build a FSM that will fetch all the expire_dates and
keep the next one, then sleep until that moment. If a new doc arrives
and its expire_date is before the one you are currently watching, it
is set as the new one to watch. When the expire_date arrives, the doc
is burnt, the new dates are processed.

What's missing :
* actual connection with couchdb. I planned to use couchbeam_changes
instead of polling
* actual burning. I believe couchbeam will give you everything you need.
* cleaning of the code, proper OTP. I did not know much at the time.

Note : It looks like your question was more on "How do I bulk delete".
I hope I wasn't too off-topic.

-- 
Matthieu RAKOTOJAONA

Mime
View raw message