Reputation: 2483
My CouchDb
database is getting bigger and I would like to remove documents by date also I would like to remove _deleted
documents by date
I know how to replicate my DB removing documents by date but:
¿Is there a way to do the same with _deleted
documents? I mean remove _deleted
documents by date
Upvotes: 4
Views: 4125
Reputation: 17942
There's not really a way to conditionally cause a deletion using filtered replication, nor can you replicate a complete removal of a document.
You have a variety of options:
{_deleted:true}
tombstone of the documents [that's how the deletion gets replicated in the first place]What is your main goal?
If you have hundreds of objects and you want to hide the old ones from the UI of all replicas, write a script to find and DELETE
/_delete:true
them from in a source/master replica and the changes will propagate.
If you have bazillions of e.g. log messages and you need to free up space by forgetting old ones, write a script to find and _purge
and finally _compact
, then run it on every replica. But for a case like that, it might be better to rotate databases instead, e.g. manually "shard" or bin into a different database each week, and every week simply drop the N+1 weeks old database on each replica.
Upvotes: 3
Reputation: 3690
If your database is getting bigger, this is probably due to the versionning of your documents. A simple way to free some space is to run database compaction (Documentation)
As for _deleted documents, you can only REALLY delete them by purging
Therefore, it's not recommended to purge _deleted documents. It should only be done to remove very important files such as credentials.
Upvotes: 2