With the revisions feature enabled, let's execute this code:
using (var session = store.OpenAsyncSession())
await session.StoreAsync(new User
Name = "Ayende Rahien"
If we inspect the document we will see that the following revision were created:
Figure 1: Revisions
This is a revision of the document (you can navigate to the document by clicking on
See the current document) which is stored on the revisions storage.
Now, let's modify the original document. This would create another revision:
Figure 2: Revisions, Modified
As you can see, we have a full audit record of all the changes that were made to the document.
You can access the revisions of a specific document by the document's ID ("users/1").
Or you can access a specific revision by its change vector or by a specific date.
Accessing a revision by a change vector would return a specific revision,
while accessing a revision by a date would return the revision on this specific date if exists,
and if not it would return the revision right before this date.
List<User> revisions = await session
.GetForAsync<User>("users/1", start: 0, pageSize: 25);
List<MetadataAsDictionary> revisionsMetadata = await session
.GetMetadataForAsync("users/1", start: 0, pageSize: 25);
User revison = await session
User revisonAtYearAgo = await session
Now, let's delete the document.
The document would be removed but a revision will be created, so you aren't going to lose the audit trail if the document is deleted.
In order to see orphaned revisions (revisions of deleted documents), you can go to the
Documents > Revisions Bin section in the studio,
which would list all revisions without existing document:
Figure 3: Revisions, Deleted
If you'll go and create another document with this ID (users/1), then the revision won't be shown anymore in the Revision Bin section,
but you can navigate to the document and see it's revisions, including the deleted ones.
Clicking on the revision we can also navigate to the other revisions of this document:
Figure 4: Revisions, Deleted - other revisions
The revisions feature attempts to make things as simple as possible. Once it is enabled, you'll automatically get the appropriate audit trail.