---
title: "Revisions and Other Features"
url: "https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features"
version: "6.2"
language: "csharp"
---

# Revisions and Other Features

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.java.md), [Python](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.python.md), [PHP](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.php.md), [Node.js](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - This page describes relationships between Revisions and other RavenDB features, including -
>   - When is revisions creation triggered by other features
>   - How revisions are supported by other features
>
> - In this page:
>   - [Revisions and Counters](#revisions-and-counters)
>   - [Revisions and Time Series](#revisions-and-time-series)
>   - [Revisions and Attachments](#revisions-and-attachments)
>   - [Revisions and Replication](#revisions-and-replication)
>   - [Revisions and ETL](#revisions-and-etl)
>   - [Revisions and Backup](#revisions-and-backup)
>   - [Revisions and Data Subscriptions](#revisions-and-data-subscriptions)
>   - [Revisions Import and Export](#revisions-import-and-export)

## Revisions and Counters

### Revisions creation:

- A document revision will be created when:
  - A new counter is **created** on the document.
  - A counter is **deleted** from the document.

- A revision will Not be created upon modifying the value of an existing [counter](https://docs.ravendb.net/6.2/document-extensions/counters/overview.md).

### Stored data:

- A revision that is created for a document that contains counters  
  will have the `@counters-snapshot` property in its **metadata**.

- This property holds the counters' names and values at the time when the revision was created.

- The counter's value stored in the  revision's metadata is the **accumulated value** from all nodes.  
  It does not specify the value of the counter on each individual node.

- Sample revision metadata:

```json
{
  ...
  "@metadata": {
      "@counters-snapshot": {
          "counterName1": 7,
          "counterName2": 42
      },
  ...
  }
}
```

### Reverted data:

When a document is [reverted](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.md) to a revision that has counters,
the counters from the revision are restored to functionality along with their values.

### Extract counters data from revisions:

Use [GetMetadataFor](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.md#get-revisions-metadata) to get the revisions metadata for a specified document,  
and then extract the counters' data.

#### Sync

```csharp
// Use GetMetadataFor to get revisions metadata for document 'orders/1-A'
List<IMetadataDictionary> revisionsMetadata = session
  .Advanced.Revisions.GetMetadataFor(id: "orders/1-A");

// Extract the counters data from the metadata
List<MetadataAsDictionary> countersDataInRevisions = revisionsMetadata
  .Where(metadata =>
      metadata.ContainsKey(Constants.Documents.Metadata.RevisionCounters))
  .Select(metadata =>
      (MetadataAsDictionary)metadata[Constants.Documents.Metadata.RevisionCounters])
  .ToList();
```

#### Async

```csharp
// Use GetMetadataForAsync to get revisions metadata for document 'orders/1-A'
List<IMetadataDictionary> revisionsMetadata = await asyncSession
  .Advanced.Revisions.GetMetadataForAsync(id: "orders/1-A");

// Extract the counters data from the metadata
List<MetadataAsDictionary> countersDataInRevisions = revisionsMetadata
  .Where(metadata =>
      metadata.ContainsKey(Constants.Documents.Metadata.RevisionCounters))
  .Select(metadata =>
      (MetadataAsDictionary)metadata[Constants.Documents.Metadata.RevisionCounters])
  .ToList();
```

## Revisions and Time Series

### Revisions Creation:

- A document revision will be created when:
  - A new time series is **created** on the document.
  - A time series is **deleted** from the document.  
    (A time series is deleted from a document when all its entries are deleted)

- A revision will Not be created upon modifying the values of an existing [time series](https://docs.ravendb.net/6.2/document-extensions/timeseries/overview.md).

### Stored Data:

- A revision that is created for a document that contains time series  
  will have the `@timeseries-snapshot` property in its **metadata**.

- This property does Not hold the time series values data,  
  it only contains the following information for the time when the revision was created:
  - The time series names
  - The number of entries in each time series
  - Dates of the first and last entry in each time series

- Read more about Revisions and Time Series [here](https://docs.ravendb.net/6.2/document-extensions/timeseries/time-series-and-other-features.md#revisions).

- Sample revision metadata:

```json
{
  ...
  "@metadata": {
      "@timeseries-snapshot": {
          "timeSeriesName1": {
              "Count": 5,
              "Start": "2023-03-22T11:25:00.9110000Z",
              "End": "2023-03-22T11:28:34.9110000Z"
          },
          "timeSeriesName2": {
               "Count": 10,
               "Start": "2023-03-22T11:26:00.3950000Z",
               "End": "2023-03-22T11:28:48.3950000Z"
          }
      },
  ...
  }
}
```

### Reverted Data:

When a document is [reverted](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.md) to a revision that has a time series:

- If the current document **contains** a time series name as in the revision:
  - The reverted document will keep the time series entries & values as it was in the current document.
  - Time series entries and values from the revision are Not restored.

- If the current document **doesn't contain** a time series name as in the revision,  
  or if the document itself was deleted:
  - The reverted document will have the time series from the revision
  - However, the entries count will be 0

## Revisions and Attachments

### Revisions Creation:

A document revision will be created when:

- A new [attachment](https://docs.ravendb.net/6.2/document-extensions/attachments/what-are-attachments.md) is **added** to the document.
- An attachment is **deleted** from the document.

### Stored Data:

- A revision that is created for a document with attachments  
  will have the `@attachments` property in its **metadata**.

- This property does Not hold the actual attachments, as the files are stored in **separate storage**.  
  The property only contains the following information for each attachment the document had when the revision was created:
  - Attachment file name
  - File content type
  - File size
  - A hash string (a reference to the file in the storage)

- Existing attachment files in the storage are Not duplicated per revision that is created when the document itself is modified.

- An attachment file is removed from RavenDB's storage only when there is no live document or a revision that refers to it.

- Sample revision metadata:

```json
{
  ...
  "@metadata": {
      "@attachments": [
          {
              "Name": "attachmentFileName.png",
              "ContentType": "image/png",
              "Size": 33241,
              "Hash": "iFg0o6D38pUcWGVlP71ddDp8SCcoEal47kG3LtWx0+Y=",
          }, 
      ],
  ...
  }
}
```

### Reverted Data:

When a document is [reverted](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.md) to a revision that has attachments,
the attachments are restored to their state when the revision was created.

## Revisions and Replication

- Revisions are transferred during [replication](https://docs.ravendb.net/6.2/server/clustering/replication/replication-overview.md) from one database instance to another.

- The revisions will be replicated by all replication types:
  - [Internal replication](https://docs.ravendb.net/6.2/server/clustering/replication/replication-overview.md#internal-replication)
  - [External replication](https://docs.ravendb.net/6.2/server/clustering/replication/replication-overview.md#external-replication)
  - [Hub/Sink replication](https://docs.ravendb.net/6.2/server/clustering/replication/replication-overview.md#hubsink-replication)

- Revisions can [help keep data consistency](https://docs.ravendb.net/6.2/server/clustering/replication/replication-overview.md#how-revisions-replication-help-data-consistency).

## Revisions and ETL

- An [ETL](https://docs.ravendb.net/6.2/server/ongoing-tasks/etl/raven.md) ongoing task does 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 document in the target database as expected.

## Revisions and Backup

Revisions are [backed up](https://docs.ravendb.net/6.2/server/ongoing-tasks/backup-overview.md#backup-contents) both by a logical-backup and by a snapshot.

## Revisions and Data Subscriptions

- Learn about revisions and data subscriptions [here](https://docs.ravendb.net/6.2/client-api/data-subscriptions/advanced-topics/subscription-with-revisioning.md).

## Revisions Import and Export

- Revisions can be imported and exported with a `.ravendbdump` file:
  - Using [the Client API](https://docs.ravendb.net/6.2/client-api/smuggler/what-is-smuggler.md)
  - From the [import](https://docs.ravendb.net/6.2/studio/database/tasks/import-data/import-data-file.md#import-options) and [export](https://docs.ravendb.net/6.2/studio/database/tasks/export-database.md#export-options) views in the Studio

- Revisions can be imported when migrating data from another [live RavenDB server](https://docs.ravendb.net/6.2/studio/database/tasks/import-data/import-from-ravendb.md#step-#4:-set-import-options).

  ![Import from Live Server](https://docs.ravendb.net/assets/images/import-from-live-server-7f13d1f92117d1b626fa5b2dbef1b2b7.png)

## See also

- [Document Revisions Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/overview.md)
- [Revert Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.md)
- [Counters: Overview](https://docs.ravendb.net/6.2/document-extensions/counters/overview.md)
- [Time Series: Overview](https://docs.ravendb.net/6.2/document-extensions/timeseries/overview.md)
- [Attachments: What are Attachments](https://docs.ravendb.net/6.2/document-extensions/attachments/what-are-attachments.md)
- [Revisions: API Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/overview.md)
- [Operations: Configuring Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/operations/configure-revisions.md)
- [Session: Loading Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.md)
- [Settings: Document Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
- [Document Extensions: Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
- [What Are Data Subscriptions](https://docs.ravendb.net/6.2/client-api/data-subscriptions/what-are-data-subscriptions.md)
- [Revisions and Data Subscriptions](https://docs.ravendb.net/6.2/client-api/data-subscriptions/advanced-topics/subscription-with-revisioning.md)
