Revisions: Revisions and Other Features



Revisions and Counters

Revisions Creation

  • A revision will not be created upon modifications to existing counter values.
  • Creating or removing a counter modifies the counter's parent document by adding the counter's name or removing it from the document's metadata, and will cause the creation of a new revision.

Stored Data

A revision created for a document that contains counters will include in its metadata a @counters-snapshot property that will hold the document's counter names and values at the time of the revision creation.
The counter's value is stored in its Accumulated form: a single sum with no specification of the Counter's value on each node.


Reverted Data

When a document is reverted to a revision that owns counters, the counters are restored to functionality along with their values.


Code Sample

Use GetMetadataFor to get a document's revisions metadata, and extract counters' data from the metadata.

// Use GetMetadataFor to get revisions metadata
List<MetadataAsDictionary> orderRevisionsMetadata =
    session
        .Advanced
        .Revisions
        .GetMetadataFor(
            id: "orders/1-A",
            start: 0,
            pageSize: 10);

// Extract counters data from the metadata
List<MetadataAsDictionary> orderCountersSnapshots = 
    orderRevisionsMetadata
        .Where(metadata => 
            metadata.ContainsKey("@counters-snapshot"))
        .Select(metadata => 
            (MetadataAsDictionary)metadata["@counters-snapshot"])
        .ToList();

Revisions and Time Series

Revisions Creation

  • A revision will not be created upon modifications to existing time series values.
  • Creating or removing a time series modifies the time series' parent document by adding the time series' name or removing it from the document's metadata, and will cause the creation of a new revision.

Stored Data

A revision created for a document that contains time series does not store the time series' data but include in its metadata a @timeseries-snapshot property with general information regarding the time series at the time of the revision creation.

Read more about Revisions and Time Series here.


Reverted Data

When a document is reverted to a point in time in which the revision had a time series:

  • The reverted document will Not contain the time series in the following cases:

    • The time series was deleted from the current document.
    • The document itself was deleted,
  • The reverted document Will contain the time series if:

    • The time series is held by the current document (i.e. neither the time series nor the document were deleted).

      Note: the time series data will not be reverted, but remain as it was before the document was reverted.

Revisions and Attachments

Revisions Creation

Adding or removing an attachment modifies the attachment's parent document by adding a reference to the attachment or removing it from the document's metadata, and will cause the creation of a new revision.


Stored Data

Documents and their revisions do not store attachments, but contain references to them in an @attachments array in their metadata.
Attachments are not replicated when new revisions are created.
An attachment will be removed from RavenDB's storage only when there is no live document or document revision that refers to it.


Reverted Data

When a document is reverted to a revision that owns attachments, the attachments are restored to their state when the revision was created.

Revisions and ETL

An ETL process will not send revisions to the destination database.
However, if revisions are enabled on the destination database, whenever the ETL process sends a modified document and the target document is overwritten, a new revision will be created for the target document as expected.

Revisions and Replication

Revisions Import and Export

Revisions and Backup

Revisions are backed up.

Revisions and Data Subscriptions

Learn about revisions and data subscriptions here.