Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 nuget
Octocat-spinner-32 scripts
Octocat-spinner-32 src
Octocat-spinner-32 tools
Octocat-spinner-32 .gitignore
Octocat-spinner-32 build.ps1
Octocat-spinner-32 licence.txt
Octocat-spinner-32 readme.md
readme.md

RavenDB.Bundles.Revisions

A RavenDB plugin and client that automatically maintains previous versions of a document, if the document has a Revision property of type int. This is an alternative to Raven's 'Versioning' bundle in that:

  • It only works on documents that have a Revision property.
  • It allows Revisions to be deleted.
  • It allows Revisions to be overwritten.
  • Your application controls the Revision number and not the plugin.
  • Your application is resposible for revision number contiguity.

While Raven's 'Versioning' bundle is designed for regulatad environments, such as healtcare, where nothing can be deleted, this bundle is more useful for applications where the document is a result of a projection (i.e. CQRS) and where the 'source of truth' comes from somewhere else and where projections / documents can easily be rebuilt.

Install

Packages are available nuget.org

Using

If you want your this plugin to automatically create revision copies add a Revision property to your document:

public class MyDocument
{
    public string Id { get; set;}
    
    public int Revision { get; set; }
}

When a revisionable document is saved, the plugin will create a copy with a new id. These copies are excluded from all indexes. You should be aware that these revisions are kept indefinitely until you have specifically deleted them or used Raven's 'Expiration' bundle to perform automatic purging.

To retireve a specific revision of a document use the LoadRevision extension method:

using(var session = store.OpenSession)
{
    var doc = session.LoadRevision("key", 2);
}

To delete a specific revision of a document:

_documentStore.DatabaseCommands.DeleteRevision("key", 2, null);
Something went wrong with that request. Please try again.