diff --git a/docs/client-api/operations/_what-are-operations-csharp.mdx b/docs/client-api/operations/_what-are-operations-csharp.mdx index 0ba2266108..8d8577460d 100644 --- a/docs/client-api/operations/_what-are-operations-csharp.mdx +++ b/docs/client-api/operations/_what-are-operations-csharp.mdx @@ -160,7 +160,7 @@ Task> SendAsync(PatchOperation * **Revisions**:        [GetRevisionsOperation](../../document-extensions/revisions/client-api/operations/get-revisions.mdx) -        [RevertRevisionsByIdOperation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx) +        [RevertRevisionsByIdOperation](../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) * **Patching**:        [PatchOperation](../../client-api/operations/patching/single-document.mdx) diff --git a/docs/document-extensions/revisions/revert-documents-to-revisions/_category_.json b/docs/document-extensions/revisions/revert-documents-to-revisions/_category_.json new file mode 100644 index 0000000000..0bf5802488 --- /dev/null +++ b/docs/document-extensions/revisions/revert-documents-to-revisions/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 2, + "label": "Revert Documents to Revisions" +} \ No newline at end of file diff --git a/docs/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx b/docs/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx similarity index 52% rename from docs/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx rename to docs/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx index 9a1c343d9e..2ddda14c1c 100644 --- a/docs/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx +++ b/docs/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx @@ -2,52 +2,127 @@ import Admonition from '@theme/Admonition'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -* This article describes how to revert specific documents to specific revisions using the `RevertRevisionsByIdOperation` operation. +* This article describes how to revert specific documents to **specific revisions**. + To revert documents from all collections (or from selected collections) to a **specific point in time**, + see [Revert documents to specific time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx). -* To revert documents from all collections (or from selected collections) to a specified point in time, - see [Revert documents to revisions](../../../../document-extensions/revisions/revert-revisions.mdx). - -* By default, the operation will be applied to the [default database](../../../../client-api/setting-up-default-database.mdx). - To operate on a different database see [switch operations to different database](../../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). - -* In this page: - * [Overview](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#overview) - * [Revert single document](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) - * [Revert multiple documents](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-multiple-documents) - * [Syntax](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#syntax) +* In this article: + * [Overview](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#overview) + * [Revert documents - using a session](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-a-session) + * [Revert documents - using an operation](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) + * [Revert single document](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-single-document) + * [Revert multiple documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-multiple-documents) + * [Syntax](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#syntax) -## Overview - -* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. - The document content will be overwritten by the content of the specified revision. -* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + + +* When reverting to a specific revision, + the document content will be overwritten by the content of the specified revision. -* Reverting a document with this operation can be executed even if the revisions configuration is disabled: - * When revisions are **enabled**: +* Reverting a document to a specific revision can be executed even if the revisions configuration is disabled: + * **When revisions are ENABLED**: Reverting the document creates a new revision containing the content of the target revision. - * When revisions are **disabled**: + * **When revisions are DISABLED**: The document is reverted to the target revision without creating a new revision. -* In addition to the document itself, reverting will impact Document Extensions as follows: +* In addition to the document itself, reverting will impact _Document Extensions_ as follows: * **Attachments**: If the target revision owns attachments, they are restored to their state when the revision was created. * **Counters**: If the target revision owns counters, they are restored to functionality with their values at the time the revision was created. * **Time series**: - Time series data is Not reverted. Learn more [here](../../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more in [Revisions and time series](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + + + + + + + +```csharp +using (var session = store.OpenSession()) +{ + // Load a document & get its change vector: + var currentOrder = session.Load("orders/830-A"); + string currentOrderCV = session.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = session.Advanced.Revisions.GetFor(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision + var previousRevision = revisions[1]; + + // Evict both entities from the session + session.Advanced.Evict(currentOrder); + session.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + session.Store(previousRevision, currentOrderCV, previousRevision.Id); + session.SaveChanges(); +} +``` + + +```csharp +using (var asyncSession = store.OpenAsyncSession()) +{ + // Load a document & get its change vector + var currentOrder = await asyncSession.LoadAsync("orders/830-A"); + string currentOrderCV = asyncSession.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = await asyncSession.Advanced.Revisions.GetForAsync(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision — the most recent past version + var previousRevision = revisions[1]; + + // Evict both entities from the session + asyncSession.Advanced.Evict(currentOrder); + asyncSession.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + asyncSession.StoreAsync(previousRevision, currentOrderCV, previousRevision.Id); + await asyncSession.SaveChangesAsync(); +} +``` + + + + + + + +* You can revert single or multiple documents to specific revisions using the `RevertRevisionsByIdOperation` operation. -* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, +* By default, the operation will be applied to the [default database](../../../client-api/setting-up-default-database.mdx). + To operate on a different database, see [switch operations to different database](../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). + +* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. + The document content will be overwritten by the content of the specified revision. + +* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + +* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, the document will be **recreated** with the content of the specified target revision and will be removed from the Revisions Bin. -##### How to obtain a revision's change-vector: + +--- + +### How to obtain a revision's change-vector: The change-vector of a revision can be obtained via: - * The Client API - follow the code in the examples [below](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) + * The Client API - follow the code in the examples [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions#revert-single-document) * Or from the document view in the Studio ![Get revision CV](./assets/get-cv-for-revision.png) @@ -58,17 +133,17 @@ The change-vector of a revision can be obtained via: This top label indicates that you are viewing a revision and not the current document. 4. Click the copy button in the Properties pane to copy this revision's change-vector to your clipboard. + - -## Revert single document + Using RavenDB's sample data, document _orders/1-A_ has a total of 7 revisions. In this example, we revert document _orders/1-A_ to its very first revision. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -76,28 +151,27 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = session.Advanced.Revisions .GetMetadataFor(id: "orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation store.Operations.Send( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("orders/1-A", revisionChangeVector)); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -105,38 +179,37 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "Orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation await store.Operations.SendAsync( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("Orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("Orders/1-A", revisionChangeVector)); } -`} - +``` + - -## Revert multiple documents + You can use the operation to revert multiple documents. Note: The documents do not need to belong to the same collection. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = session.Advanced.Revisions @@ -144,7 +217,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = session.Advanced.Revisions .GetMetadataFor(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -156,12 +229,11 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = await asyncSession.Advanced.Revisions @@ -169,7 +241,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -181,31 +253,29 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` + - -## Syntax - - - -{`Available overloads: + + +### `RevertRevisionsByIdOperation` + + +```csharp +Available overloads: ==================== public RevertRevisionsByIdOperation(string id, string cv); public RevertRevisionsByIdOperation(Dictionary idToChangeVector); -`} - +``` | Parameter | Type | Description | |----------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| | **id** | `string` | The ID of the document to revert. | -| **cv** | `string` | The change vector of the revision to which the document should be reverted. | +| **cv** | `string` | The change-vector of the revision to which the document should be reverted. | | **idToChangeVector** | `Dictionary` | A dictionary where each key is a document ID, and each value is the change-vector of the revision to which the document should be reverted. | - - - - + + \ No newline at end of file diff --git a/docs/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png b/docs/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png similarity index 100% rename from docs/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png rename to docs/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png diff --git a/versioned_docs/version-6.2/document-extensions/revisions/assets/revert-revisions-1.png b/docs/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png similarity index 100% rename from versioned_docs/version-6.2/document-extensions/revisions/assets/revert-revisions-1.png rename to docs/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png diff --git a/versioned_docs/version-6.2/document-extensions/revisions/assets/revert-revisions-2.png b/docs/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png similarity index 100% rename from versioned_docs/version-6.2/document-extensions/revisions/assets/revert-revisions-2.png rename to docs/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png diff --git a/docs/document-extensions/revisions/assets/set-point-in-time.png b/docs/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png similarity index 100% rename from docs/document-extensions/revisions/assets/set-point-in-time.png rename to docs/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png diff --git a/versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx b/docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx similarity index 81% rename from versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx rename to docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx index 9b17a718d9..01254869bc 100644 --- a/versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx +++ b/docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx @@ -1,23 +1,22 @@ --- -title: "Revert Document to Revision Operation" -sidebar_label: Revert Document to Revision -sidebar_position: 4 +title: "Revert Documents to Specific Revisions" +sidebar_label: "Revert Documents to Specific Revisions" +sidebar_position: 0 --- import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; -import RevertDocumentToRevisionCsharp from './_revert-document-to-revision-csharp.mdx'; +import RevertDocumentsToSpecificRevisionsCsharp from './_revert-documents-to-specific-revisions-csharp.mdx'; export const supportedLanguages = ["csharp"]; - + - \ No newline at end of file diff --git a/versioned_docs/version-7.0/document-extensions/revisions/revert-revisions.mdx b/docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx similarity index 76% rename from versioned_docs/version-7.0/document-extensions/revisions/revert-revisions.mdx rename to docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx index 219d09870a..fd65202796 100644 --- a/versioned_docs/version-7.0/document-extensions/revisions/revert-revisions.mdx +++ b/docs/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx @@ -1,7 +1,7 @@ --- -title: "Revert Documents to Revisions" -sidebar_label: Revert Documents to Revisions -sidebar_position: 2 +title: "Revert Documents to Specific Time" +sidebar_label: "Revert Documents to Specific Time" +sidebar_position: 1 --- import Admonition from '@theme/Admonition'; @@ -10,8 +10,9 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -# Revert Documents to Revisions * You can **revert the database to its state at a specified point in time** @@ -21,28 +22,29 @@ import LanguageContent from "@site/src/components/LanguageContent"; or revert documents from all collections as explained below. * To revert a single document (or multiple documents) to a specific revision, - see [Revert document to revision operation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx). + see [Revert documents to specific revisions](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx). * Being able to restore the database to a previous state can simplify auditing, enhance understanding of changes made over time, and facilitate instant recovery without the need to search and retrieve a stored backup. -* In this page: - * [The revisions settings view](../../document-extensions/revisions/revert-revisions.mdx#the-revisions-settings-view) - * [Revert documents](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) - * [Point in time](../../document-extensions/revisions/revert-revisions.mdx#point-in-time) - * [Time Window](../../document-extensions/revisions/revert-revisions.mdx#time-window) - * [Content reverted](../../document-extensions/revisions/revert-revisions.mdx#content-reverted) +* In this article: + * [The revisions settings view](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#the-revisions-settings-view) + * [Revert documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) + * [Point in time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time) + * [Time Window](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window) + * [Content reverted](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#content-reverted) -## The revisions settings view + + ![Document Revisions View](./assets/revert-revisions-1.png) 1. **The revisions settings view**: In the Studio, go to _Settings > Document Revisions_. From this view you can: - * [Set](../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations - * [Enforce](../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations - * [Revert](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) documents to revisions + * [Set](../../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations + * [Enforce](../../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations + * [Revert](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) documents to revisions 2. **Revision configurations**: * The ability to revert documents to their past revisions depends on revisions being created. @@ -51,23 +53,23 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Make sure that a configuration that suits your needs is defined. 3. **Revert documents**: - Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. - Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#revert-documents). - + Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. + Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents). + -## Revert documents + ![Revert Revisions](./assets/revert-revisions-2.png) -1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#point-in-time). +1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time). -2. Enter the **Time Window**. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#time-window). +2. Enter the **Time Window**. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window). 3. Revert **All collections** in the database, or toggle to select **Specific collections** to revert. - - +--- + ## Point in time ![Set point in time](./assets/set-point-in-time.png) @@ -89,7 +91,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Any of these documents that own revisions will be **reverted** to the revision created at the specified Point in Time or to the latest revision preceding this time. - * When [setting a limit](../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) + * When [setting a limit](../../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) then only the most recent revisions are kept for the document. If all of these revisions were created AFTER the Point in Time then the oldest revision will be the one we revert to, even though that revision is newer than the specified time. @@ -104,8 +106,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; - - +--- + ## Time window * Revisions are ordered in the _revisions storage_ by their change-vector, and Not by creation time. @@ -146,7 +148,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; | 6) `Users/1` | 13.2.2023 01:00 | => Document Users/1 will be reverted to this revision | | 7) `Users/5` | 11.2.2023 01:00 | => Document Users/5 will be reverted to this revision +
STOP the search for more Users/5 revisions | | 8) `Users/5` | 11.2.2023 03:00 | | -| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | +| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | | 10) `Users/6` | 11.2.2023 01:00 | | | . . . | | | @@ -178,7 +180,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; - +--- ## Content reverted @@ -192,7 +194,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Document extensions: * **Time series** - Time series data is Not reverted. Learn more [here](../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more [here](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). * **Attachments** When a document is reverted to a revision that owns attachments, the attachments are restored to their state when the revision was created. @@ -200,7 +202,6 @@ import LanguageContent from "@site/src/components/LanguageContent"; When a document is reverted to a revision that owns counters, the counters are restored to functionality along with their values from that revision. - - - + +
\ No newline at end of file diff --git a/versioned_docs/version-6.2/client-api/operations/_what-are-operations-csharp.mdx b/versioned_docs/version-6.2/client-api/operations/_what-are-operations-csharp.mdx index 6d3f64e35f..8a7fcb1b49 100644 --- a/versioned_docs/version-6.2/client-api/operations/_what-are-operations-csharp.mdx +++ b/versioned_docs/version-6.2/client-api/operations/_what-are-operations-csharp.mdx @@ -160,7 +160,7 @@ Task> SendAsync(PatchOperation * **Revisions**:        [GetRevisionsOperation](../../document-extensions/revisions/client-api/operations/get-revisions.mdx) -        [RevertRevisionsByIdOperation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx) +        [RevertRevisionsByIdOperation](../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) * **Patching**:        [PatchOperation](../../client-api/operations/patching/single-document.mdx) diff --git a/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_category_.json b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_category_.json new file mode 100644 index 0000000000..0bf5802488 --- /dev/null +++ b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 2, + "label": "Revert Documents to Revisions" +} \ No newline at end of file diff --git a/versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx similarity index 52% rename from versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx index 9a1c343d9e..2ddda14c1c 100644 --- a/versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx +++ b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx @@ -2,52 +2,127 @@ import Admonition from '@theme/Admonition'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -* This article describes how to revert specific documents to specific revisions using the `RevertRevisionsByIdOperation` operation. +* This article describes how to revert specific documents to **specific revisions**. + To revert documents from all collections (or from selected collections) to a **specific point in time**, + see [Revert documents to specific time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx). -* To revert documents from all collections (or from selected collections) to a specified point in time, - see [Revert documents to revisions](../../../../document-extensions/revisions/revert-revisions.mdx). - -* By default, the operation will be applied to the [default database](../../../../client-api/setting-up-default-database.mdx). - To operate on a different database see [switch operations to different database](../../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). - -* In this page: - * [Overview](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#overview) - * [Revert single document](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) - * [Revert multiple documents](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-multiple-documents) - * [Syntax](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#syntax) +* In this article: + * [Overview](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#overview) + * [Revert documents - using a session](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-a-session) + * [Revert documents - using an operation](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) + * [Revert single document](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-single-document) + * [Revert multiple documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-multiple-documents) + * [Syntax](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#syntax) -## Overview - -* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. - The document content will be overwritten by the content of the specified revision. -* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + + +* When reverting to a specific revision, + the document content will be overwritten by the content of the specified revision. -* Reverting a document with this operation can be executed even if the revisions configuration is disabled: - * When revisions are **enabled**: +* Reverting a document to a specific revision can be executed even if the revisions configuration is disabled: + * **When revisions are ENABLED**: Reverting the document creates a new revision containing the content of the target revision. - * When revisions are **disabled**: + * **When revisions are DISABLED**: The document is reverted to the target revision without creating a new revision. -* In addition to the document itself, reverting will impact Document Extensions as follows: +* In addition to the document itself, reverting will impact _Document Extensions_ as follows: * **Attachments**: If the target revision owns attachments, they are restored to their state when the revision was created. * **Counters**: If the target revision owns counters, they are restored to functionality with their values at the time the revision was created. * **Time series**: - Time series data is Not reverted. Learn more [here](../../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more in [Revisions and time series](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + + + + + + + +```csharp +using (var session = store.OpenSession()) +{ + // Load a document & get its change vector: + var currentOrder = session.Load("orders/830-A"); + string currentOrderCV = session.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = session.Advanced.Revisions.GetFor(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision + var previousRevision = revisions[1]; + + // Evict both entities from the session + session.Advanced.Evict(currentOrder); + session.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + session.Store(previousRevision, currentOrderCV, previousRevision.Id); + session.SaveChanges(); +} +``` + + +```csharp +using (var asyncSession = store.OpenAsyncSession()) +{ + // Load a document & get its change vector + var currentOrder = await asyncSession.LoadAsync("orders/830-A"); + string currentOrderCV = asyncSession.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = await asyncSession.Advanced.Revisions.GetForAsync(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision — the most recent past version + var previousRevision = revisions[1]; + + // Evict both entities from the session + asyncSession.Advanced.Evict(currentOrder); + asyncSession.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + asyncSession.StoreAsync(previousRevision, currentOrderCV, previousRevision.Id); + await asyncSession.SaveChangesAsync(); +} +``` + + + + + + + +* You can revert single or multiple documents to specific revisions using the `RevertRevisionsByIdOperation` operation. -* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, +* By default, the operation will be applied to the [default database](../../../client-api/setting-up-default-database.mdx). + To operate on a different database, see [switch operations to different database](../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). + +* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. + The document content will be overwritten by the content of the specified revision. + +* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + +* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, the document will be **recreated** with the content of the specified target revision and will be removed from the Revisions Bin. -##### How to obtain a revision's change-vector: + +--- + +### How to obtain a revision's change-vector: The change-vector of a revision can be obtained via: - * The Client API - follow the code in the examples [below](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) + * The Client API - follow the code in the examples [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions#revert-single-document) * Or from the document view in the Studio ![Get revision CV](./assets/get-cv-for-revision.png) @@ -58,17 +133,17 @@ The change-vector of a revision can be obtained via: This top label indicates that you are viewing a revision and not the current document. 4. Click the copy button in the Properties pane to copy this revision's change-vector to your clipboard. + - -## Revert single document + Using RavenDB's sample data, document _orders/1-A_ has a total of 7 revisions. In this example, we revert document _orders/1-A_ to its very first revision. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -76,28 +151,27 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = session.Advanced.Revisions .GetMetadataFor(id: "orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation store.Operations.Send( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("orders/1-A", revisionChangeVector)); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -105,38 +179,37 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "Orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation await store.Operations.SendAsync( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("Orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("Orders/1-A", revisionChangeVector)); } -`} - +``` + - -## Revert multiple documents + You can use the operation to revert multiple documents. Note: The documents do not need to belong to the same collection. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = session.Advanced.Revisions @@ -144,7 +217,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = session.Advanced.Revisions .GetMetadataFor(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -156,12 +229,11 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = await asyncSession.Advanced.Revisions @@ -169,7 +241,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -181,31 +253,29 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` + - -## Syntax - - - -{`Available overloads: + + +### `RevertRevisionsByIdOperation` + + +```csharp +Available overloads: ==================== public RevertRevisionsByIdOperation(string id, string cv); public RevertRevisionsByIdOperation(Dictionary idToChangeVector); -`} - +``` | Parameter | Type | Description | |----------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| | **id** | `string` | The ID of the document to revert. | -| **cv** | `string` | The change vector of the revision to which the document should be reverted. | +| **cv** | `string` | The change-vector of the revision to which the document should be reverted. | | **idToChangeVector** | `Dictionary` | A dictionary where each key is a document ID, and each value is the change-vector of the revision to which the document should be reverted. | - - - - + + \ No newline at end of file diff --git a/versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png similarity index 100% rename from versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png diff --git a/versioned_docs/version-7.0/document-extensions/revisions/assets/revert-revisions-1.png b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png similarity index 100% rename from versioned_docs/version-7.0/document-extensions/revisions/assets/revert-revisions-1.png rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png diff --git a/versioned_docs/version-7.0/document-extensions/revisions/assets/revert-revisions-2.png b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png similarity index 100% rename from versioned_docs/version-7.0/document-extensions/revisions/assets/revert-revisions-2.png rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png diff --git a/versioned_docs/version-7.0/document-extensions/revisions/assets/set-point-in-time.png b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png similarity index 100% rename from versioned_docs/version-7.0/document-extensions/revisions/assets/set-point-in-time.png rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png diff --git a/docs/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx similarity index 81% rename from docs/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx index 9b17a718d9..01254869bc 100644 --- a/docs/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx +++ b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx @@ -1,23 +1,22 @@ --- -title: "Revert Document to Revision Operation" -sidebar_label: Revert Document to Revision -sidebar_position: 4 +title: "Revert Documents to Specific Revisions" +sidebar_label: "Revert Documents to Specific Revisions" +sidebar_position: 0 --- import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; -import RevertDocumentToRevisionCsharp from './_revert-document-to-revision-csharp.mdx'; +import RevertDocumentsToSpecificRevisionsCsharp from './_revert-documents-to-specific-revisions-csharp.mdx'; export const supportedLanguages = ["csharp"]; - + - \ No newline at end of file diff --git a/versioned_docs/version-6.2/document-extensions/revisions/revert-revisions.mdx b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx similarity index 76% rename from versioned_docs/version-6.2/document-extensions/revisions/revert-revisions.mdx rename to versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx index 219d09870a..fd65202796 100644 --- a/versioned_docs/version-6.2/document-extensions/revisions/revert-revisions.mdx +++ b/versioned_docs/version-6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx @@ -1,7 +1,7 @@ --- -title: "Revert Documents to Revisions" -sidebar_label: Revert Documents to Revisions -sidebar_position: 2 +title: "Revert Documents to Specific Time" +sidebar_label: "Revert Documents to Specific Time" +sidebar_position: 1 --- import Admonition from '@theme/Admonition'; @@ -10,8 +10,9 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -# Revert Documents to Revisions * You can **revert the database to its state at a specified point in time** @@ -21,28 +22,29 @@ import LanguageContent from "@site/src/components/LanguageContent"; or revert documents from all collections as explained below. * To revert a single document (or multiple documents) to a specific revision, - see [Revert document to revision operation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx). + see [Revert documents to specific revisions](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx). * Being able to restore the database to a previous state can simplify auditing, enhance understanding of changes made over time, and facilitate instant recovery without the need to search and retrieve a stored backup. -* In this page: - * [The revisions settings view](../../document-extensions/revisions/revert-revisions.mdx#the-revisions-settings-view) - * [Revert documents](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) - * [Point in time](../../document-extensions/revisions/revert-revisions.mdx#point-in-time) - * [Time Window](../../document-extensions/revisions/revert-revisions.mdx#time-window) - * [Content reverted](../../document-extensions/revisions/revert-revisions.mdx#content-reverted) +* In this article: + * [The revisions settings view](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#the-revisions-settings-view) + * [Revert documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) + * [Point in time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time) + * [Time Window](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window) + * [Content reverted](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#content-reverted) -## The revisions settings view + + ![Document Revisions View](./assets/revert-revisions-1.png) 1. **The revisions settings view**: In the Studio, go to _Settings > Document Revisions_. From this view you can: - * [Set](../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations - * [Enforce](../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations - * [Revert](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) documents to revisions + * [Set](../../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations + * [Enforce](../../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations + * [Revert](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) documents to revisions 2. **Revision configurations**: * The ability to revert documents to their past revisions depends on revisions being created. @@ -51,23 +53,23 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Make sure that a configuration that suits your needs is defined. 3. **Revert documents**: - Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. - Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#revert-documents). - + Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. + Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents). + -## Revert documents + ![Revert Revisions](./assets/revert-revisions-2.png) -1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#point-in-time). +1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time). -2. Enter the **Time Window**. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#time-window). +2. Enter the **Time Window**. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window). 3. Revert **All collections** in the database, or toggle to select **Specific collections** to revert. - - +--- + ## Point in time ![Set point in time](./assets/set-point-in-time.png) @@ -89,7 +91,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Any of these documents that own revisions will be **reverted** to the revision created at the specified Point in Time or to the latest revision preceding this time. - * When [setting a limit](../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) + * When [setting a limit](../../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) then only the most recent revisions are kept for the document. If all of these revisions were created AFTER the Point in Time then the oldest revision will be the one we revert to, even though that revision is newer than the specified time. @@ -104,8 +106,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; - - +--- + ## Time window * Revisions are ordered in the _revisions storage_ by their change-vector, and Not by creation time. @@ -146,7 +148,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; | 6) `Users/1` | 13.2.2023 01:00 | => Document Users/1 will be reverted to this revision | | 7) `Users/5` | 11.2.2023 01:00 | => Document Users/5 will be reverted to this revision +
STOP the search for more Users/5 revisions | | 8) `Users/5` | 11.2.2023 03:00 | | -| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | +| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | | 10) `Users/6` | 11.2.2023 01:00 | | | . . . | | | @@ -178,7 +180,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; - +--- ## Content reverted @@ -192,7 +194,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Document extensions: * **Time series** - Time series data is Not reverted. Learn more [here](../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more [here](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). * **Attachments** When a document is reverted to a revision that owns attachments, the attachments are restored to their state when the revision was created. @@ -200,7 +202,6 @@ import LanguageContent from "@site/src/components/LanguageContent"; When a document is reverted to a revision that owns counters, the counters are restored to functionality along with their values from that revision. - - - + +
\ No newline at end of file diff --git a/versioned_docs/version-7.0/client-api/operations/_what-are-operations-csharp.mdx b/versioned_docs/version-7.0/client-api/operations/_what-are-operations-csharp.mdx index 27607c9064..ccbb8c4fd4 100644 --- a/versioned_docs/version-7.0/client-api/operations/_what-are-operations-csharp.mdx +++ b/versioned_docs/version-7.0/client-api/operations/_what-are-operations-csharp.mdx @@ -160,7 +160,7 @@ Task> SendAsync(PatchOperation * **Revisions**:        [GetRevisionsOperation](../../document-extensions/revisions/client-api/operations/get-revisions.mdx) -        [RevertRevisionsByIdOperation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx) +        [RevertRevisionsByIdOperation](../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) * **Patching**:        [PatchOperation](../../client-api/operations/patching/single-document.mdx) diff --git a/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_category_.json b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_category_.json new file mode 100644 index 0000000000..0bf5802488 --- /dev/null +++ b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 2, + "label": "Revert Documents to Revisions" +} \ No newline at end of file diff --git a/versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx similarity index 52% rename from versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx rename to versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx index 9a1c343d9e..2ddda14c1c 100644 --- a/versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx +++ b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx @@ -2,52 +2,127 @@ import Admonition from '@theme/Admonition'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -* This article describes how to revert specific documents to specific revisions using the `RevertRevisionsByIdOperation` operation. +* This article describes how to revert specific documents to **specific revisions**. + To revert documents from all collections (or from selected collections) to a **specific point in time**, + see [Revert documents to specific time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx). -* To revert documents from all collections (or from selected collections) to a specified point in time, - see [Revert documents to revisions](../../../../document-extensions/revisions/revert-revisions.mdx). - -* By default, the operation will be applied to the [default database](../../../../client-api/setting-up-default-database.mdx). - To operate on a different database see [switch operations to different database](../../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). - -* In this page: - * [Overview](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#overview) - * [Revert single document](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) - * [Revert multiple documents](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-multiple-documents) - * [Syntax](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#syntax) +* In this article: + * [Overview](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#overview) + * [Revert documents - using a session](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-a-session) + * [Revert documents - using an operation](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) + * [Revert single document](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-single-document) + * [Revert multiple documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-multiple-documents) + * [Syntax](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#syntax) -## Overview - -* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. - The document content will be overwritten by the content of the specified revision. -* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + + +* When reverting to a specific revision, + the document content will be overwritten by the content of the specified revision. -* Reverting a document with this operation can be executed even if the revisions configuration is disabled: - * When revisions are **enabled**: +* Reverting a document to a specific revision can be executed even if the revisions configuration is disabled: + * **When revisions are ENABLED**: Reverting the document creates a new revision containing the content of the target revision. - * When revisions are **disabled**: + * **When revisions are DISABLED**: The document is reverted to the target revision without creating a new revision. -* In addition to the document itself, reverting will impact Document Extensions as follows: +* In addition to the document itself, reverting will impact _Document Extensions_ as follows: * **Attachments**: If the target revision owns attachments, they are restored to their state when the revision was created. * **Counters**: If the target revision owns counters, they are restored to functionality with their values at the time the revision was created. * **Time series**: - Time series data is Not reverted. Learn more [here](../../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more in [Revisions and time series](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + + + + + + + +```csharp +using (var session = store.OpenSession()) +{ + // Load a document & get its change vector: + var currentOrder = session.Load("orders/830-A"); + string currentOrderCV = session.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = session.Advanced.Revisions.GetFor(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision + var previousRevision = revisions[1]; + + // Evict both entities from the session + session.Advanced.Evict(currentOrder); + session.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + session.Store(previousRevision, currentOrderCV, previousRevision.Id); + session.SaveChanges(); +} +``` + + +```csharp +using (var asyncSession = store.OpenAsyncSession()) +{ + // Load a document & get its change vector + var currentOrder = await asyncSession.LoadAsync("orders/830-A"); + string currentOrderCV = asyncSession.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = await asyncSession.Advanced.Revisions.GetForAsync(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision — the most recent past version + var previousRevision = revisions[1]; + + // Evict both entities from the session + asyncSession.Advanced.Evict(currentOrder); + asyncSession.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + asyncSession.StoreAsync(previousRevision, currentOrderCV, previousRevision.Id); + await asyncSession.SaveChangesAsync(); +} +``` + + + + + + + +* You can revert single or multiple documents to specific revisions using the `RevertRevisionsByIdOperation` operation. -* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, +* By default, the operation will be applied to the [default database](../../../client-api/setting-up-default-database.mdx). + To operate on a different database, see [switch operations to different database](../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). + +* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. + The document content will be overwritten by the content of the specified revision. + +* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + +* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, the document will be **recreated** with the content of the specified target revision and will be removed from the Revisions Bin. -##### How to obtain a revision's change-vector: + +--- + +### How to obtain a revision's change-vector: The change-vector of a revision can be obtained via: - * The Client API - follow the code in the examples [below](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) + * The Client API - follow the code in the examples [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions#revert-single-document) * Or from the document view in the Studio ![Get revision CV](./assets/get-cv-for-revision.png) @@ -58,17 +133,17 @@ The change-vector of a revision can be obtained via: This top label indicates that you are viewing a revision and not the current document. 4. Click the copy button in the Properties pane to copy this revision's change-vector to your clipboard. + - -## Revert single document + Using RavenDB's sample data, document _orders/1-A_ has a total of 7 revisions. In this example, we revert document _orders/1-A_ to its very first revision. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -76,28 +151,27 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = session.Advanced.Revisions .GetMetadataFor(id: "orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation store.Operations.Send( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("orders/1-A", revisionChangeVector)); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -105,38 +179,37 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "Orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation await store.Operations.SendAsync( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("Orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("Orders/1-A", revisionChangeVector)); } -`} - +``` + - -## Revert multiple documents + You can use the operation to revert multiple documents. Note: The documents do not need to belong to the same collection. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = session.Advanced.Revisions @@ -144,7 +217,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = session.Advanced.Revisions .GetMetadataFor(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -156,12 +229,11 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = await asyncSession.Advanced.Revisions @@ -169,7 +241,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -181,31 +253,29 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` + - -## Syntax - - - -{`Available overloads: + + +### `RevertRevisionsByIdOperation` + + +```csharp +Available overloads: ==================== public RevertRevisionsByIdOperation(string id, string cv); public RevertRevisionsByIdOperation(Dictionary idToChangeVector); -`} - +``` | Parameter | Type | Description | |----------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| | **id** | `string` | The ID of the document to revert. | -| **cv** | `string` | The change vector of the revision to which the document should be reverted. | +| **cv** | `string` | The change-vector of the revision to which the document should be reverted. | | **idToChangeVector** | `Dictionary` | A dictionary where each key is a document ID, and each value is the change-vector of the revision to which the document should be reverted. | - - - - + + \ No newline at end of file diff --git a/versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png similarity index 100% rename from versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png rename to versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png diff --git a/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png new file mode 100644 index 0000000000..c2724ad33e Binary files /dev/null and b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png differ diff --git a/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png new file mode 100644 index 0000000000..a3db14a7f7 Binary files /dev/null and b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png differ diff --git a/versioned_docs/version-7.1/document-extensions/revisions/assets/set-point-in-time.png b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png similarity index 100% rename from versioned_docs/version-7.1/document-extensions/revisions/assets/set-point-in-time.png rename to versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png diff --git a/versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx similarity index 81% rename from versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx rename to versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx index 9b17a718d9..01254869bc 100644 --- a/versioned_docs/version-7.0/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx +++ b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx @@ -1,23 +1,22 @@ --- -title: "Revert Document to Revision Operation" -sidebar_label: Revert Document to Revision -sidebar_position: 4 +title: "Revert Documents to Specific Revisions" +sidebar_label: "Revert Documents to Specific Revisions" +sidebar_position: 0 --- import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; -import RevertDocumentToRevisionCsharp from './_revert-document-to-revision-csharp.mdx'; +import RevertDocumentsToSpecificRevisionsCsharp from './_revert-documents-to-specific-revisions-csharp.mdx'; export const supportedLanguages = ["csharp"]; - + - \ No newline at end of file diff --git a/docs/document-extensions/revisions/revert-revisions.mdx b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx similarity index 76% rename from docs/document-extensions/revisions/revert-revisions.mdx rename to versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx index 219d09870a..fd65202796 100644 --- a/docs/document-extensions/revisions/revert-revisions.mdx +++ b/versioned_docs/version-7.0/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx @@ -1,7 +1,7 @@ --- -title: "Revert Documents to Revisions" -sidebar_label: Revert Documents to Revisions -sidebar_position: 2 +title: "Revert Documents to Specific Time" +sidebar_label: "Revert Documents to Specific Time" +sidebar_position: 1 --- import Admonition from '@theme/Admonition'; @@ -10,8 +10,9 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -# Revert Documents to Revisions * You can **revert the database to its state at a specified point in time** @@ -21,28 +22,29 @@ import LanguageContent from "@site/src/components/LanguageContent"; or revert documents from all collections as explained below. * To revert a single document (or multiple documents) to a specific revision, - see [Revert document to revision operation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx). + see [Revert documents to specific revisions](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx). * Being able to restore the database to a previous state can simplify auditing, enhance understanding of changes made over time, and facilitate instant recovery without the need to search and retrieve a stored backup. -* In this page: - * [The revisions settings view](../../document-extensions/revisions/revert-revisions.mdx#the-revisions-settings-view) - * [Revert documents](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) - * [Point in time](../../document-extensions/revisions/revert-revisions.mdx#point-in-time) - * [Time Window](../../document-extensions/revisions/revert-revisions.mdx#time-window) - * [Content reverted](../../document-extensions/revisions/revert-revisions.mdx#content-reverted) +* In this article: + * [The revisions settings view](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#the-revisions-settings-view) + * [Revert documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) + * [Point in time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time) + * [Time Window](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window) + * [Content reverted](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#content-reverted) -## The revisions settings view + + ![Document Revisions View](./assets/revert-revisions-1.png) 1. **The revisions settings view**: In the Studio, go to _Settings > Document Revisions_. From this view you can: - * [Set](../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations - * [Enforce](../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations - * [Revert](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) documents to revisions + * [Set](../../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations + * [Enforce](../../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations + * [Revert](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) documents to revisions 2. **Revision configurations**: * The ability to revert documents to their past revisions depends on revisions being created. @@ -51,23 +53,23 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Make sure that a configuration that suits your needs is defined. 3. **Revert documents**: - Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. - Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#revert-documents). - + Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. + Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents). + -## Revert documents + ![Revert Revisions](./assets/revert-revisions-2.png) -1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#point-in-time). +1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time). -2. Enter the **Time Window**. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#time-window). +2. Enter the **Time Window**. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window). 3. Revert **All collections** in the database, or toggle to select **Specific collections** to revert. - - +--- + ## Point in time ![Set point in time](./assets/set-point-in-time.png) @@ -89,7 +91,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Any of these documents that own revisions will be **reverted** to the revision created at the specified Point in Time or to the latest revision preceding this time. - * When [setting a limit](../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) + * When [setting a limit](../../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) then only the most recent revisions are kept for the document. If all of these revisions were created AFTER the Point in Time then the oldest revision will be the one we revert to, even though that revision is newer than the specified time. @@ -104,8 +106,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; - - +--- + ## Time window * Revisions are ordered in the _revisions storage_ by their change-vector, and Not by creation time. @@ -146,7 +148,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; | 6) `Users/1` | 13.2.2023 01:00 | => Document Users/1 will be reverted to this revision | | 7) `Users/5` | 11.2.2023 01:00 | => Document Users/5 will be reverted to this revision +
STOP the search for more Users/5 revisions | | 8) `Users/5` | 11.2.2023 03:00 | | -| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | +| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | | 10) `Users/6` | 11.2.2023 01:00 | | | . . . | | | @@ -178,7 +180,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; - +--- ## Content reverted @@ -192,7 +194,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Document extensions: * **Time series** - Time series data is Not reverted. Learn more [here](../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more [here](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). * **Attachments** When a document is reverted to a revision that owns attachments, the attachments are restored to their state when the revision was created. @@ -200,7 +202,6 @@ import LanguageContent from "@site/src/components/LanguageContent"; When a document is reverted to a revision that owns counters, the counters are restored to functionality along with their values from that revision. - - - + +
\ No newline at end of file diff --git a/versioned_docs/version-7.1/client-api/operations/_what-are-operations-csharp.mdx b/versioned_docs/version-7.1/client-api/operations/_what-are-operations-csharp.mdx index e37c702e25..e88b7e28ec 100644 --- a/versioned_docs/version-7.1/client-api/operations/_what-are-operations-csharp.mdx +++ b/versioned_docs/version-7.1/client-api/operations/_what-are-operations-csharp.mdx @@ -160,7 +160,7 @@ Task> SendAsync(PatchOperation * **Revisions**:        [GetRevisionsOperation](../../document-extensions/revisions/client-api/operations/get-revisions.mdx) -        [RevertRevisionsByIdOperation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx) +        [RevertRevisionsByIdOperation](../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) * **Patching**:        [PatchOperation](../../client-api/operations/patching/single-document.mdx) diff --git a/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_category_.json b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_category_.json new file mode 100644 index 0000000000..0bf5802488 --- /dev/null +++ b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 2, + "label": "Revert Documents to Revisions" +} \ No newline at end of file diff --git a/versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx similarity index 52% rename from versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx rename to versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx index 9a1c343d9e..2ddda14c1c 100644 --- a/versioned_docs/version-6.2/document-extensions/revisions/client-api/operations/_revert-document-to-revision-csharp.mdx +++ b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/_revert-documents-to-specific-revisions-csharp.mdx @@ -2,52 +2,127 @@ import Admonition from '@theme/Admonition'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -* This article describes how to revert specific documents to specific revisions using the `RevertRevisionsByIdOperation` operation. +* This article describes how to revert specific documents to **specific revisions**. + To revert documents from all collections (or from selected collections) to a **specific point in time**, + see [Revert documents to specific time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx). -* To revert documents from all collections (or from selected collections) to a specified point in time, - see [Revert documents to revisions](../../../../document-extensions/revisions/revert-revisions.mdx). - -* By default, the operation will be applied to the [default database](../../../../client-api/setting-up-default-database.mdx). - To operate on a different database see [switch operations to different database](../../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). - -* In this page: - * [Overview](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#overview) - * [Revert single document](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) - * [Revert multiple documents](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-multiple-documents) - * [Syntax](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#syntax) +* In this article: + * [Overview](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#overview) + * [Revert documents - using a session](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-a-session) + * [Revert documents - using an operation](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-documents-using-an-operation) + * [Revert single document](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-single-document) + * [Revert multiple documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#revert-multiple-documents) + * [Syntax](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx#syntax) -## Overview - -* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. - The document content will be overwritten by the content of the specified revision. -* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + + +* When reverting to a specific revision, + the document content will be overwritten by the content of the specified revision. -* Reverting a document with this operation can be executed even if the revisions configuration is disabled: - * When revisions are **enabled**: +* Reverting a document to a specific revision can be executed even if the revisions configuration is disabled: + * **When revisions are ENABLED**: Reverting the document creates a new revision containing the content of the target revision. - * When revisions are **disabled**: + * **When revisions are DISABLED**: The document is reverted to the target revision without creating a new revision. -* In addition to the document itself, reverting will impact Document Extensions as follows: +* In addition to the document itself, reverting will impact _Document Extensions_ as follows: * **Attachments**: If the target revision owns attachments, they are restored to their state when the revision was created. * **Counters**: If the target revision owns counters, they are restored to functionality with their values at the time the revision was created. * **Time series**: - Time series data is Not reverted. Learn more [here](../../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more in [Revisions and time series](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + + + + + + + +```csharp +using (var session = store.OpenSession()) +{ + // Load a document & get its change vector: + var currentOrder = session.Load("orders/830-A"); + string currentOrderCV = session.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = session.Advanced.Revisions.GetFor(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision + var previousRevision = revisions[1]; + + // Evict both entities from the session + session.Advanced.Evict(currentOrder); + session.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + session.Store(previousRevision, currentOrderCV, previousRevision.Id); + session.SaveChanges(); +} +``` + + +```csharp +using (var asyncSession = store.OpenAsyncSession()) +{ + // Load a document & get its change vector + var currentOrder = await asyncSession.LoadAsync("orders/830-A"); + string currentOrderCV = asyncSession.Advanced.GetChangeVectorFor(currentOrder); + + // Get the revisions of this document + var revisions = await asyncSession.Advanced.Revisions.GetForAsync(currentOrder.Id); + + // Choose a specific revision to revert to: + // revisions[0] contains the current document version + // revisions[1] is the latest actual revision — the most recent past version + var previousRevision = revisions[1]; + + // Evict both entities from the session + asyncSession.Advanced.Evict(currentOrder); + asyncSession.Advanced.Evict(previousRevision); + + // Store the previous revision content as the current document + asyncSession.StoreAsync(previousRevision, currentOrderCV, previousRevision.Id); + await asyncSession.SaveChangesAsync(); +} +``` + + + + + + + +* You can revert single or multiple documents to specific revisions using the `RevertRevisionsByIdOperation` operation. -* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, +* By default, the operation will be applied to the [default database](../../../client-api/setting-up-default-database.mdx). + To operate on a different database, see [switch operations to different database](../../../client-api/operations/how-to/switch-operations-to-a-different-database.mdx). + +* To revert a document to a specific revision, provide the document ID and the change-vector of the target revision to the `RevertRevisionsByIdOperation` operation. + The document content will be overwritten by the content of the specified revision. + +* An exception will be thrown if the revision's change-vector is not found, does not exist for the specified document, or belongs to a different document. + +* When executing this operation on a document that had revisions and was deleted, placing it in the Revisions Bin, the document will be **recreated** with the content of the specified target revision and will be removed from the Revisions Bin. -##### How to obtain a revision's change-vector: + +--- + +### How to obtain a revision's change-vector: The change-vector of a revision can be obtained via: - * The Client API - follow the code in the examples [below](../../../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx#revert-single-document) + * The Client API - follow the code in the examples [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions#revert-single-document) * Or from the document view in the Studio ![Get revision CV](./assets/get-cv-for-revision.png) @@ -58,17 +133,17 @@ The change-vector of a revision can be obtained via: This top label indicates that you are viewing a revision and not the current document. 4. Click the copy button in the Properties pane to copy this revision's change-vector to your clipboard. + - -## Revert single document + Using RavenDB's sample data, document _orders/1-A_ has a total of 7 revisions. In this example, we revert document _orders/1-A_ to its very first revision. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -76,28 +151,27 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = session.Advanced.Revisions .GetMetadataFor(id: "orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation store.Operations.Send( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("orders/1-A", revisionChangeVector)); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the document you wish to revert // ============================================================== @@ -105,38 +179,37 @@ In this example, we revert document _orders/1-A_ to its very first revision. var revisionsMetadata = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "Orders/1-A"); - // Get the CV of the revision you wish to revert to: - // ================================================= + // Get the change-vector of the revision you wish to revert to: + // ============================================================ // Note: revisionsMetadata[0] is the latest revision, // so specify the index of the revision you want. // In this example, it will be the very first revision of the document: var numberOfRevisions = revisionsMetadata.Count(); - var changeVector = revisionsMetadata[numberOfRevisions-1] + var revisionChangeVector = revisionsMetadata[numberOfRevisions-1] .GetString(Constants.Documents.Metadata.ChangeVector); // Execute the operation await store.Operations.SendAsync( // Pass the document ID and the change-vector of the revision to revert to - new RevertRevisionsByIdOperation("Orders/1-A", changeVector)); + new RevertRevisionsByIdOperation("Orders/1-A", revisionChangeVector)); } -`} - +``` + - -## Revert multiple documents + You can use the operation to revert multiple documents. Note: The documents do not need to belong to the same collection. - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = session.Advanced.Revisions @@ -144,7 +217,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = session.Advanced.Revisions .GetMetadataFor(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -156,12 +229,11 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Get the revisions metadata for the documents you wish to revert var revisionsMetadata1 = await asyncSession.Advanced.Revisions @@ -169,7 +241,7 @@ Note: The documents do not need to belong to the same collection. var revisionsMetadata2 = await asyncSession.Advanced.Revisions .GetMetadataForAsync(id: "users/999"); - // Get the CV of the revisions you wish to revert to + // Get the change-vector of the revisions you wish to revert to var changeVector1 = revisionsMetadata1[2] .GetString(Constants.Documents.Metadata.ChangeVector); var changeVector2 = revisionsMetadata1[3] @@ -181,31 +253,29 @@ Note: The documents do not need to belong to the same collection. new RevertRevisionsByIdOperation(new Dictionary() { { "orders/1-A", changeVector1 }, { "users/999", changeVector2 } })); } -`} - +``` + - -## Syntax - - - -{`Available overloads: + + +### `RevertRevisionsByIdOperation` + + +```csharp +Available overloads: ==================== public RevertRevisionsByIdOperation(string id, string cv); public RevertRevisionsByIdOperation(Dictionary idToChangeVector); -`} - +``` | Parameter | Type | Description | |----------------------|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| | **id** | `string` | The ID of the document to revert. | -| **cv** | `string` | The change vector of the revision to which the document should be reverted. | +| **cv** | `string` | The change-vector of the revision to which the document should be reverted. | | **idToChangeVector** | `Dictionary` | A dictionary where each key is a document ID, and each value is the change-vector of the revision to which the document should be reverted. | - - - - + + \ No newline at end of file diff --git a/versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png similarity index 100% rename from versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/assets/get-cv-for-revision.png rename to versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/get-cv-for-revision.png diff --git a/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png new file mode 100644 index 0000000000..c2724ad33e Binary files /dev/null and b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-1.png differ diff --git a/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png new file mode 100644 index 0000000000..a3db14a7f7 Binary files /dev/null and b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/revert-revisions-2.png differ diff --git a/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png new file mode 100644 index 0000000000..72edbfa203 Binary files /dev/null and b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/assets/set-point-in-time.png differ diff --git a/versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx similarity index 81% rename from versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx rename to versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx index 9b17a718d9..01254869bc 100644 --- a/versioned_docs/version-7.1/document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx +++ b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx @@ -1,23 +1,22 @@ --- -title: "Revert Document to Revision Operation" -sidebar_label: Revert Document to Revision -sidebar_position: 4 +title: "Revert Documents to Specific Revisions" +sidebar_label: "Revert Documents to Specific Revisions" +sidebar_position: 0 --- import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; -import RevertDocumentToRevisionCsharp from './_revert-document-to-revision-csharp.mdx'; +import RevertDocumentsToSpecificRevisionsCsharp from './_revert-documents-to-specific-revisions-csharp.mdx'; export const supportedLanguages = ["csharp"]; - + - \ No newline at end of file diff --git a/versioned_docs/version-7.1/document-extensions/revisions/revert-revisions.mdx b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx similarity index 76% rename from versioned_docs/version-7.1/document-extensions/revisions/revert-revisions.mdx rename to versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx index 219d09870a..fd65202796 100644 --- a/versioned_docs/version-7.1/document-extensions/revisions/revert-revisions.mdx +++ b/versioned_docs/version-7.1/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx @@ -1,7 +1,7 @@ --- -title: "Revert Documents to Revisions" -sidebar_label: Revert Documents to Revisions -sidebar_position: 2 +title: "Revert Documents to Specific Time" +sidebar_label: "Revert Documents to Specific Time" +sidebar_position: 1 --- import Admonition from '@theme/Admonition'; @@ -10,8 +10,9 @@ import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; +import ContentFrame from '@site/src/components/ContentFrame'; +import Panel from '@site/src/components/Panel'; -# Revert Documents to Revisions * You can **revert the database to its state at a specified point in time** @@ -21,28 +22,29 @@ import LanguageContent from "@site/src/components/LanguageContent"; or revert documents from all collections as explained below. * To revert a single document (or multiple documents) to a specific revision, - see [Revert document to revision operation](../../document-extensions/revisions/client-api/operations/revert-document-to-revision.mdx). + see [Revert documents to specific revisions](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-revisions.mdx). * Being able to restore the database to a previous state can simplify auditing, enhance understanding of changes made over time, and facilitate instant recovery without the need to search and retrieve a stored backup. -* In this page: - * [The revisions settings view](../../document-extensions/revisions/revert-revisions.mdx#the-revisions-settings-view) - * [Revert documents](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) - * [Point in time](../../document-extensions/revisions/revert-revisions.mdx#point-in-time) - * [Time Window](../../document-extensions/revisions/revert-revisions.mdx#time-window) - * [Content reverted](../../document-extensions/revisions/revert-revisions.mdx#content-reverted) +* In this article: + * [The revisions settings view](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#the-revisions-settings-view) + * [Revert documents](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) + * [Point in time](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time) + * [Time Window](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window) + * [Content reverted](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#content-reverted) -## The revisions settings view + + ![Document Revisions View](./assets/revert-revisions-1.png) 1. **The revisions settings view**: In the Studio, go to _Settings > Document Revisions_. From this view you can: - * [Set](../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations - * [Enforce](../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations - * [Revert](../../document-extensions/revisions/revert-revisions.mdx#revert-documents) documents to revisions + * [Set](../../../studio/database/settings/document-revisions.mdx#revisions-configuration) revision configurations + * [Enforce](../../../studio/database/settings/document-revisions.mdx#enforce-configuration) revision configurations + * [Revert](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents) documents to revisions 2. **Revision configurations**: * The ability to revert documents to their past revisions depends on revisions being created. @@ -51,23 +53,23 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Make sure that a configuration that suits your needs is defined. 3. **Revert documents**: - Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. - Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#revert-documents). - + Click the _Revert Revisions_ button to revert documents from all or selected collections to a specified point in time. + Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#revert-documents). + -## Revert documents + ![Revert Revisions](./assets/revert-revisions-2.png) -1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#point-in-time). +1. Enter the **Point in Time** to which you would like to revert the documents. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#point-in-time). -2. Enter the **Time Window**. Learn more [below](../../document-extensions/revisions/revert-revisions.mdx#time-window). +2. Enter the **Time Window**. Learn more [below](../../../document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.mdx#time-window). 3. Revert **All collections** in the database, or toggle to select **Specific collections** to revert. - - +--- + ## Point in time ![Set point in time](./assets/set-point-in-time.png) @@ -89,7 +91,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Any of these documents that own revisions will be **reverted** to the revision created at the specified Point in Time or to the latest revision preceding this time. - * When [setting a limit](../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) + * When [setting a limit](../../../studio/database/settings/document-revisions.mdx#limit-revisions) on the number of revisions that are kept (by number or by age) then only the most recent revisions are kept for the document. If all of these revisions were created AFTER the Point in Time then the oldest revision will be the one we revert to, even though that revision is newer than the specified time. @@ -104,8 +106,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; - - +--- + ## Time window * Revisions are ordered in the _revisions storage_ by their change-vector, and Not by creation time. @@ -146,7 +148,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; | 6) `Users/1` | 13.2.2023 01:00 | => Document Users/1 will be reverted to this revision | | 7) `Users/5` | 11.2.2023 01:00 | => Document Users/5 will be reverted to this revision +
STOP the search for more Users/5 revisions | | 8) `Users/5` | 11.2.2023 03:00 | | -| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | +| 9) `Users/9` | 10.2.2023 01:00 | => Document Users/9 will Not be reverted to this revision +
STOP the search in this list | | 10) `Users/6` | 11.2.2023 01:00 | | | . . . | | | @@ -178,7 +180,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; - +--- ## Content reverted @@ -192,7 +194,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * Document extensions: * **Time series** - Time series data is Not reverted. Learn more [here](../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). + Time series data is Not reverted. Learn more [here](../../../document-extensions/revisions/revisions-and-other-features.mdx#reverted-data-1). * **Attachments** When a document is reverted to a revision that owns attachments, the attachments are restored to their state when the revision was created. @@ -200,7 +202,6 @@ import LanguageContent from "@site/src/components/LanguageContent"; When a document is reverted to a revision that owns counters, the counters are restored to functionality along with their values from that revision. - - - + +
\ No newline at end of file