cancel
Showing results for 
Search instead for 
Did you mean: 

Can I purge old versions of a document?

Joe_Cullin
Champ in-the-making
Champ in-the-making

We have a text field where we store a block of html, an "article body". We allow our users to include images in the article body, and save them inline as base-64 data attributes in the image tag. That seemed like a great shortcut initially: we thought images would be small and infrequent, and we had planned on making a better UX soon after our initial rollout. However, over time, our users have been including more, larger images into their articles. Performance -- really simple NXQL queries -- has gotten worse and worse.

We have a plan to rework our UI, to store images in separate docs. I'm concerned about the existing docs though. Even if we convert them to our new format—with much smaller documents—multiple old versions of those docs will still be hanging around, taking up space in our database.

TLDR: Is there a way to purge old versions of a doc from the db, just keeping the most recent version?

For example, if a doc is at version 0.6, I'd love to purge versions 1-5 from the database.

We're using mongodb. I can see that each version is stored as a separate document. (I read that in the docs and I see it in my test db.) Is there a way to remove some of those docs without breaking things? Alternatively, can I edit those old versions directly in mongodb without breaking them? I don't care about losing the version data. We have backups. I just need a way to stop the system from timing out all the time.

1 REPLY 1

Joe_Cullin
Champ in-the-making
Champ in-the-making

I also asked Nuxeo support, and they answered me. You can treat versions just like any other document, referencing them by uid. I was able to use the REST api to delete them.