diff --git a/docs/data-archival/References/_category_.json b/docs/data-archival/References/_category_.json new file mode 100644 index 0000000000..c3eb56d647 --- /dev/null +++ b/docs/data-archival/References/_category_.json @@ -0,0 +1,4 @@ +{ + "position": 7, + "label": "References" +} diff --git a/docs/data-archival/References/client-api-references.mdx b/docs/data-archival/References/client-api-references.mdx new file mode 100644 index 0000000000..950e6a39a5 --- /dev/null +++ b/docs/data-archival/References/client-api-references.mdx @@ -0,0 +1,31 @@ +--- +title: "Client API References" +hide_table_of_contents: true +sidebar_label: "Client API References" +sidebar_position: 1 +--- + +import Admonition from '@theme/Admonition'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; +import LanguageContent from "@site/src/components/LanguageContent"; + +# Data Archival: Client API References + + + +Refer to the following links for managing data archival via the Client API: + + * [Enable archiving - from the Client API](../../data-archival/enable-data-archiving#enable-archiving---from-the-client-api) + * [Schedule a SINGLE document for archiving - from the Client API](../../data-archival/schedule-document-archiving#schedule-a-single-document-for-archiving---from-the-client-api) + * [Schedule MULTIPLE documents for archiving - from the Client API](../../data-archival/schedule-document-archiving#schedule-multiple-documents-for-archiving---from-the-client-api) + * [Unarchive documents - from the Client API](../../data-archival/unarchiving-documents#unarchive-documents---from-the-client-api) + * [Archived documents and indexing](../../data-archival/archived-documents-and-other-features#archived-documents-and-indexing) + * [Archived documents and subscriptions](../../data-archival/archived-documents-and-other-features#archived-documents-and-subscriptions) + * [Archived documents and smuggler (export/import)](../../data-archival/archived-documents-and-other-features#archived-documents-and-smuggler-exportimport) + * [Archived documents and expiration](../../data-archival/archived-documents-and-other-features#archived-documents-and-expiration) + * [Archived documents and ETL](../../data-archival/archived-documents-and-other-features#archived-documents-and-etl) + + diff --git a/docs/data-archival/References/studio-references.mdx b/docs/data-archival/References/studio-references.mdx new file mode 100644 index 0000000000..879db57838 --- /dev/null +++ b/docs/data-archival/References/studio-references.mdx @@ -0,0 +1,31 @@ +--- +title: "Studio References" +hide_table_of_contents: true +sidebar_label: "Studio References" +sidebar_position: 0 +--- + +import Admonition from '@theme/Admonition'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; +import LanguageContent from "@site/src/components/LanguageContent"; + +# Data Archival: Studio References + + + +Refer to the following links for managing data archival via the Studio: + + * [The archived document](../../data-archival/overview#the-archived-document) + * [Enable archiving](../../data-archival/enable-data-archiving#enable-archiving---from-the-studio) + * [Schedule a single document for archiving](../../data-archival/enable-data-archiving#enable-archiving---from-the-studio) + * [Schedule multiple documents for archiving](../../data-archival/schedule-document-archiving#schedule-multiple-documents-for-archiving---from-the-studio) + * [Configure how a static index handles archived documents](../../data-archival/archived-documents-and-other-features#configuring-archived-document-processing-for-a-static-index---from-the-studio) + * [Configure how a subscription task handles archived documents](../../data-archival/archived-documents-and-other-features#configuring-archived-document-processing-for-a-data-subscription-task---from-the-studio) + * [Export archived documents](../../data-archival/archived-documents-and-other-features#export-archived-documents---from-the-studio) + * [Import archived documents](../../data-archival/archived-documents-and-other-features#import-archived-documents---from-the-studio) + * [Unarchive documents](../../data-archival/unarchiving-documents#unarchive-documents---from-the-studio) + + diff --git a/docs/data-archival/archived-documents-and-other-features.mdx b/docs/data-archival/archived-documents-and-other-features.mdx index 5d70e9ca59..ca31212a45 100644 --- a/docs/data-archival/archived-documents-and-other-features.mdx +++ b/docs/data-archival/archived-documents-and-other-features.mdx @@ -2,7 +2,7 @@ title: "Archived Documents and Other Features" hide_table_of_contents: true sidebar_label: Archived Documents and Other Features -sidebar_position: 3 +sidebar_position: 4 --- import Admonition from '@theme/Admonition'; @@ -14,8 +14,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; export const supportedLanguages = ["csharp"]; +# Archived Documents and Other Features -# Archived Documents and Other Features @@ -36,6 +36,7 @@ export const supportedLanguages = ["csharp"]; * Limiting processing to either archived or non-archived documents may improve performance by reducing workload and transfer volume. * Learn more below about how various RavenDB features interact with archived documents. + * In this article: * [Archived documents and indexing](../data-archival/archived-documents-and-other-features.mdx#archived-documents-and-indexing) * [Archived documents and querying](../data-archival/archived-documents-and-other-features.mdx#archived-documents-and-querying) @@ -49,6 +50,9 @@ export const supportedLanguages = ["csharp"]; * [Archived documents and patching](../data-archival/archived-documents-and-other-features.mdx#archived-documents-and-patching) + +--- + ## Archived documents and indexing * Indexing performance may decline as the database grows, since a larger number of documents increases indexing load, expands index size, and can eventually reduce query speed. @@ -77,6 +81,7 @@ export const supportedLanguages = ["csharp"]; * `ExcludeArchived`: only non-archived documents are processed by the index. * `IncludeArchived`: both archived and non-archived documents are processed by the index. * `ArchivedOnly`: only archived documents are processed by the index. + ##### Configuring archived document processing for a static index - from the Client API You can configure how a static index handles archived documents when creating the index using the Client API. @@ -88,8 +93,8 @@ Example: - -{`public class Orders_ByOrderDate : +```csharp +public class Orders_ByOrderDate : AbstractIndexCreationTask { public class IndexEntry @@ -112,12 +117,11 @@ Example: Raven.Client.Documents.DataArchival.ArchivedDataProcessingBehavior.IncludeArchived; } } -`} - +``` - -{`public class Orders_ByOrderDate_JS : AbstractJavaScriptIndexCreationTask +```csharp +public class Orders_ByOrderDate_JS : AbstractJavaScriptIndexCreationTask { public Orders_ByOrderDate_JS() { @@ -137,12 +141,11 @@ Example: Raven.Client.Documents.DataArchival.ArchivedDataProcessingBehavior.IncludeArchived; } } -`} - +``` - -{`var indexDefinition = new IndexDefinitionBuilder() +```csharp +var indexDefinition = new IndexDefinitionBuilder() { Map = orders => from order in orders select new { order.OrderedAt } @@ -158,12 +161,12 @@ indexDefinition.ArchivedDataProcessingBehavior = ArchivedDataProcessingBehavior.IncludeArchived; store.Maintenance.Send(new PutIndexesOperation(indexDefinition)); -`} - +``` - + + When a static-index is configured to include **both** archived and non-archived documents in its processing, @@ -173,8 +176,8 @@ For example: - -{`public class Orders_ByArchivedStatus : +```csharp +public class Orders_ByArchivedStatus : AbstractIndexCreationTask { public class IndexEntry @@ -212,12 +215,11 @@ For example: Raven.Client.Documents.DataArchival.ArchivedDataProcessingBehavior.IncludeArchived; } } -`} - +``` - -{`public class Orders_ByArchivedStatus_JS : AbstractJavaScriptIndexCreationTask +```csharp +public class Orders_ByArchivedStatus_JS : AbstractJavaScriptIndexCreationTask { public Orders_ByArchivedStatus_JS() { @@ -244,12 +246,11 @@ For example: Raven.Client.Documents.DataArchival.ArchivedDataProcessingBehavior.IncludeArchived; } } -`} - +``` - -{`var indexDefinition = new IndexDefinition +```csharp +var indexDefinition = new IndexDefinition { Name = "Orders/ByArchivedStatus", @@ -271,12 +272,12 @@ For example: }; store.Maintenance.Send(new PutIndexesOperation(indexDefinition)); -`} - +``` - + + ##### Configuring archived document processing for a static index - from the Studio You can configure how a static index handles archived documents directly from the Studio. @@ -295,7 +296,7 @@ This setting will **override** the global configuration defined by the [Indexing ![Processing options](./assets/processing-options.png) - +--- ## Archived documents and querying @@ -318,7 +319,7 @@ This setting will **override** the global configuration defined by the [Indexing * the explicit setting in the index definition, which overrides the global configuration key. * The index's archived data processing behavior can be modified after its creation using the Studio or the Client API. - +--- ## Archived documents and subscriptions @@ -337,6 +338,7 @@ This setting will **override** the global configuration defined by the [Indexing * `ExcludeArchived`: only non-archived documents are processed by the subscription query. * `IncludeArchived`: both archived and non-archived documents are processed by the subscription query. * `ArchivedOnly`: only archived documents are processed by the subscription query. + ##### Configuring archived document processing for a data subscription task - from the Client API You can configure how a subscription task handles archived documents when creating the subscription using the Client API. @@ -348,8 +350,8 @@ Example: - -{`var subscriptionName = store.Subscriptions +```csharp +var subscriptionName = store.Subscriptions .Create(new SubscriptionCreationOptions() { Name = "ArchivedOrdersSubscription", @@ -359,12 +361,11 @@ Example: // You can set the behavior to 'ExcludeArchived', 'IncludeArchived, or 'ArchivedOnly' }); -`} - +``` - -{`var subscriptionName = store.Subscriptions +```csharp +var subscriptionName = store.Subscriptions .Create(new SubscriptionCreationOptions() { Name = "ArchivedOrdersSubscription", @@ -375,12 +376,12 @@ Example: // You can set the behavior to 'ExcludeArchived', 'IncludeArchived, or 'ArchivedOnly' }); -`} - +``` + ##### Configuring archived document processing for a data subscription task - from the Studio You can configure how a subscription task handles archived documents directly from the Studio. @@ -396,7 +397,7 @@ This setting will **override** the global configuration defined by the [Subscrip * **Include Archived**: Process both archived and non-archived documents. * **Archived Only**: Process only archived documents. - +--- ## Archived documents and document extensions @@ -419,7 +420,7 @@ This setting will **override** the global configuration defined by the [Subscrip * No revision is created at the time the server archives a document, even if the Revisions feature is enabled. * However, if you modify an archived document (when Revisions are enabled), a revision is created for that document - and that revision is archived as well. - +--- ## Archived documents and smuggler (export/import) @@ -434,15 +435,14 @@ By default, archived documents are **included** in the operation. In this example, exported data **excludes** archived documents: - -{`var exportOperation = store.Smuggler.ExportAsync( +```csharp +var exportOperation = store.Smuggler.ExportAsync( new DatabaseSmugglerExportOptions() - \{ + { // Export only non-archived documents: IncludeArchived = false - \}, "DestinationFilePath"); -`} - + }, "DestinationFilePath"); +``` @@ -452,24 +452,25 @@ In this example, exported data **excludes** archived documents: In this example, imported data **includes** archived documents: - -{`var importOperation = store.Smuggler.ImportAsync( +```csharp +var importOperation = store.Smuggler.ImportAsync( new DatabaseSmugglerImportOptions() - \{ + { // Include archived documents in the import: IncludeArchived = true - \}, "SourceFilePath"); -`} - + }, "SourceFilePath"); +``` + ##### Export archived documents - from the Studio ![Export archived documents](./assets/export-archived-documents.png) 1. Go to **Tasks > Export Database**. 2. Toggle the **Include archived documents** option to control whether archived documents are included in the database export. + ##### Import archived documents - from the Studio ![Import archived documents](./assets/import-archived-documents.png) @@ -477,7 +478,7 @@ In this example, imported data **includes** archived documents: 1. Go to **Tasks > Import Data**. 2. Toggle the **Include archived documents** option to control whether archived documents are included in the import. - +--- ## Archived documents and expiration @@ -491,23 +492,22 @@ In this example, imported data **includes** archived documents: to schedule it for archiving and expiration, respectively: - -{`\{ +```json +{ "Name": "Wilman Kala", "Phone": "90-224 8858", ... - "@metadata": \{ + "@metadata": { "@archive-at": "2026-01-06T22:45:30.018Z", "@expires": "2026-07-06T22:45:30.018Z", "@collection": "Companies", ... - \} -\} -`} - + } +} +``` - +--- ## Archived documents and ETL @@ -521,20 +521,19 @@ In this example, imported data **includes** archived documents: * In the following example, the ETL script checks whether the document is archived, and skips it if it is: - -{`var isArchived = this['@metadata']['@archived']; +```javascript +var isArchived = this['@metadata']['@archived']; -if (isArchived === true) \{ +if (isArchived === true) { return; // Do not process archived documents -\} +} // Transfer only non-archived documents to the target loadToOrders(this); -`} - +``` - +--- ## Archived documents and backup @@ -544,7 +543,7 @@ loadToOrders(this); * When restoring a database from a backup, archived documents are restored as well, and their archived status is preserved. - +--- ## Archived documents and replication @@ -552,7 +551,7 @@ Archived documents are included in [Internal](../server/clustering/replication/r [External](../server/clustering/replication/replication-overview.mdx#external-replication) replication, and [Hub/Sink](../server/clustering/replication/replication-overview.mdx#hubsink-replication) replication - no special configuration is required. - +--- ## Archived documents and patching @@ -567,9 +566,6 @@ no special configuration is required. (see this [clone document example](../client-api/operations/patching/single-document.mdx#clone-document)) the cloned document will Not be archived, and the `@archived: true` property will be removed from the cloned document. - - - \ No newline at end of file +--> diff --git a/docs/data-archival/configuration.mdx b/docs/data-archival/configuration.mdx new file mode 100644 index 0000000000..b465869d79 --- /dev/null +++ b/docs/data-archival/configuration.mdx @@ -0,0 +1,84 @@ +--- +title: "Configuration" +hide_table_of_contents: true +sidebar_label: "Configuration" +sidebar_position: 6 +--- + +import Admonition from '@theme/Admonition'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; +import LanguageContent from "@site/src/components/LanguageContent"; + +# Data archival configuration + + + +* For an overview of what configuration options are and how they can be applied, + see the [Configuration Overview](../server/configuration/configuration-options) article. + +* The following configuration options are available for data archival: + * [Indexing.Static.ArchivedDataProcessingBehavior](../todo..) + * [Indexing.Auto.ArchivedDataProcessingBehavior](../todo..) + * [Subscriptions.ArchivedDataProcessingBehavior](../todo..) + + + +--- + + + +## Indexing.Static.ArchivedDataProcessingBehavior + +* Set the default processing behavior for archived documents in static indexes. +* This setting applies only to static indexes that use _Documents_ as their data source. + It does not apply to indexes based on _Time Series_ or _Counters_, which default to `IncludeArchived`. + +--- + +- **Type**: `enum ArchivedDataProcessingBehavior`: + * `ExcludeArchived`: only non-archived documents are processed by the index. + * `IncludeArchived`: both archived and non-archived documents are processed by the index. + * `ArchivedOnly`: only archived documents are processed by the index. + +- **Default**: `ExcludeArchived` + +- **Scope**: Server-wide, or per database + + + + + +## Indexing.Auto.ArchivedDataProcessingBehavior + +The default processing behavior for archived documents in auto-indexes. + +- **Type**: `enum ArchivedDataProcessingBehavior`: + * `ExcludeArchived`: only non-archived documents are processed by the index. + * `IncludeArchived`: both archived and non-archived documents are processed by the index. + * `ArchivedOnly`: only archived documents are processed by the index. + +- **Default**: `ExcludeArchived` + +- **Scope**: Server-wide, or per database + + + + + +## Subscriptions.ArchivedDataProcessingBehavior + +The default processing behavior for archived documents in a subscription query. + +- **Type**: `enum ArchivedDataProcessingBehavior`: + * `ExcludeArchived`: only non-archived documents are processed by the subscription query. + * `IncludeArchived`: both archived and non-archived documents are processed by the subscription query. + * `ArchivedOnly`: only archived documents are processed by the subscription query. + +- **Default**: `ExcludeArchived` + +- **Scope**: Server-wide, or per database + + diff --git a/docs/data-archival/enable-data-archiving.mdx b/docs/data-archival/enable-data-archiving.mdx index 98c8598c91..ef3b9825da 100644 --- a/docs/data-archival/enable-data-archiving.mdx +++ b/docs/data-archival/enable-data-archiving.mdx @@ -2,7 +2,7 @@ title: "Enable Data Archiving" hide_table_of_contents: true sidebar_label: Enable Data Archiving -sidebar_position: 1 +sidebar_position: 2 --- import Admonition from '@theme/Admonition'; @@ -14,8 +14,8 @@ import LanguageContent from "@site/src/components/LanguageContent"; export const supportedLanguages = ["csharp"]; +# Enable Data Archiving -# Enable Data Archiving @@ -36,15 +36,19 @@ export const supportedLanguages = ["csharp"]; * [Enable archiving - from the Studio](../data-archival/enable-data-archiving.mdx#enable-archiving---from-the-studio) + +--- + ## Enable archiving - from the Client API Use `ConfigureDataArchivalOperation` to enable archiving for the database and configure the archiving task. + **Example**: - -{`// Define the archival configuration object +```csharp +// Define the archival configuration object var configuration = new DataArchivalConfiguration { // Enable archiving @@ -63,12 +67,11 @@ var configureArchivalOp = new ConfigureDataArchivalOperation(configuration); // Execute the operation by passing it to Maintenance.Send store.Maintenance.Send(configureArchivalOp); -`} - +``` - -{`// Define the archival configuration object +```csharp +// Define the archival configuration object var configuration = new DataArchivalConfiguration { // Enable archiving @@ -87,38 +90,36 @@ var configureArchivalOp = new ConfigureDataArchivalOperation(configuration); // Execute the operation by passing it to Maintenance.SendAsync await store.Maintenance.SendAsync(configureArchivalOp); -`} - +``` + **Syntax**: - -{`public ConfigureDataArchivalOperation(DataArchivalConfiguration configuration) -`} - +```csharp +public ConfigureDataArchivalOperation(DataArchivalConfiguration configuration) +``` - -{`public class DataArchivalConfiguration -\{ - public bool Disabled \{ get; set; \} - public long? ArchiveFrequencyInSec \{ get; set; \} - public long? MaxItemsToProcess \{ get; set; \} -\} -`} - +```csharp +public class DataArchivalConfiguration +{ + public bool Disabled { get; set; } + public long? ArchiveFrequencyInSec { get; set; } + public long? MaxItemsToProcess { get; set; } +} +``` -| Parameter | Type | Description | -|---------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **Disabled** | `bool` | `true` - archiving is disabled for the entire database (default).
`false` - archiving is enabled for the database. | -| **ArchiveFrequencyInSec** | `long?` | Frequency (in seconds) at which the server scans for documents scheduled for archiving. Default: `60` | -| **MaxItemsToProcess** | `long?` | The maximum number of documents the archiving task will process in a single run (i.e., each time it is triggered by the configured frequency). Default: `int.MaxValue` | - +| Parameter | Type | Description | +|---------------------------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **Disabled** | `bool` | `true` - archiving is disabled for the entire database (default).
`false` - archiving is enabled for the database. | +| **ArchiveFrequencyInSec** | `long?`| Frequency (in seconds) at which the server scans for documents scheduled for archiving. Default: `60` | +| **MaxItemsToProcess** | `long?`| The maximum number of documents the archiving task will process in a single run (i.e., each time it is triggered by the configured frequency). Default: `int.MaxValue` | +--- ## Enable archiving - from the Studio @@ -131,9 +132,6 @@ await store.Maintenance.SendAsync(configureArchivalOp); 4. Toggle on to customize the maximum number of documents the archiving task will process in a single run. 5. Click Save to apply your settings. - - -
\ No newline at end of file +--> diff --git a/docs/data-archival/feature-hub.mdx b/docs/data-archival/feature-hub.mdx new file mode 100644 index 0000000000..7edd3c3e60 --- /dev/null +++ b/docs/data-archival/feature-hub.mdx @@ -0,0 +1,49 @@ +--- +title: "Feature Hub / Start" +hide_table_of_contents: true +sidebar_label: "Feature Hub / Start" +sidebar_position: 0 +--- + +import Admonition from '@theme/Admonition'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; +import LanguageContent from "@site/src/components/LanguageContent"; + +# Data Archival: Feature Hub / Start + + +## Overview + +Data Archival in RavenDB lets you keep documents long-term without slowing down your active database. +By adding an `@archive-at` timestamp to a document’s metadata, you can tell RavenDB when to move it into an archived state. +Archived documents are compressed, excluded from indexes and subscriptions by default, but still fully retrievable and can be unarchived at any time. +This keeps indexes small, improves performance, and reduces storage costs while preserving history. + +--- + +## Use cases + +A company maintains an Orders collection with millions of records, but only needs to search and process orders from the last 6 months. +Older orders must remain available for audits and customer service. +By enabling archiving older orders, RavenDB automatically compresses and excludes them from indexing and subscriptions. +The team gets faster queries and smaller indexes, while still being able to load any archived order if needed. + +--- + +## Blog posts + +* [Indexing only recent data - adventures with large datasets & archiving](https://ayende.com/blog/201442-B/indexing-only-recent-data-adventures-with-large-datasets-archiving) + +--- + +## Documentation articles + +* [Overview](../data-archival/overview) +* [Enable data archiving](../data-archival/enable-data-archiving) +* [Schedule data archiving](../data-archival/schedule-document-archiving) +* [Archived Documents and Other Features](../data-archival/archived-documents-and-other-features) +* [Unarchiving Documents](../data-archival/unarchiving-documents) +* [Configuration](../data-archival/configuration) diff --git a/docs/data-archival/overview.mdx b/docs/data-archival/overview.mdx index 767a5ae4db..ad0b5d0216 100644 --- a/docs/data-archival/overview.mdx +++ b/docs/data-archival/overview.mdx @@ -2,7 +2,7 @@ title: "Data Archival Overview" hide_table_of_contents: true sidebar_label: Overview -sidebar_position: 0 +sidebar_position: 1 --- import Admonition from '@theme/Admonition'; @@ -13,6 +13,7 @@ import LanguageSwitcher from "@site/src/components/LanguageSwitcher"; import LanguageContent from "@site/src/components/LanguageContent"; # Data Archival Overview + * As a database grows, basic functions like indexing can slow down. @@ -36,6 +37,9 @@ import LanguageContent from "@site/src/components/LanguageContent"; * [Licensing](../data-archival/overview.mdx#licensing) + +--- + ## Overview * **Enable the archiving feature** @@ -66,7 +70,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; * An archived document can be unarchived. Learn more in the dedicated article: [Unarchiving documents](../data-archival/unarchiving-documents.mdx). - +--- ## The archived document @@ -99,12 +103,9 @@ A document that has been archived is compressed and marked with both a metadata 1. This icon indicates the document is archived. - +--- ## Licensing The archival feature is available with the **Enterprise** license. -Learn more about licensing in [Licensing overview](../start/licensing/licensing-overview.mdx). - - - +Learn more about licensing in [Licensing overview](../start/licensing/licensing-overview.mdx). diff --git a/docs/data-archival/schedule-document-archiving.mdx b/docs/data-archival/schedule-document-archiving.mdx index f1ceab77d0..844c1a7400 100644 --- a/docs/data-archival/schedule-document-archiving.mdx +++ b/docs/data-archival/schedule-document-archiving.mdx @@ -2,7 +2,7 @@ title: "Schedule Document Archiving" hide_table_of_contents: true sidebar_label: Schedule Document Archiving -sidebar_position: 2 +sidebar_position: 3 --- import Admonition from '@theme/Admonition'; @@ -15,7 +15,7 @@ import LanguageContent from "@site/src/components/LanguageContent"; export const supportedLanguages = ["csharp"]; -# Schedule Document Archiving +# Schedule Document Archiving @@ -43,6 +43,9 @@ export const supportedLanguages = ["csharp"]; * [Schedule MULTIPLE documents for archiving - from the Studio](../data-archival/schedule-document-archiving.mdx#schedule-multiple-documents-for-archiving---from-the-studio) + +--- + ## Schedule a SINGLE document for archiving - from the Client API To schedule a single document for archival from the Client API, @@ -50,8 +53,8 @@ add the `@archive-at` property directly to the document metadata as follows: - -{`using (var session = store.OpenSession()) +```csharp +using (var session = store.OpenSession()) { // Load the document to schedule for archiving var company = session.Load("companies/91-A"); @@ -66,12 +69,11 @@ add the `@archive-at` property directly to the document metadata as follows: // Save the changes session.SaveChanges(); } -`} - +``` - -{`using (var asyncSession = store.OpenAsyncSession()) +```csharp +using (var asyncSession = store.OpenAsyncSession()) { // Load the document to schedule for archiving var company = await asyncSession.LoadAsync("companies/91-A"); @@ -86,14 +88,13 @@ add the `@archive-at` property directly to the document metadata as follows: // Save the changes await asyncSession.SaveChangesAsync(); } -`} - +``` Learn more about modifying the metadata of a document in [Modifying Document Metadata](../client-api/session/how-to/get-and-modify-entity-metadata.mdx). - +--- ## Schedule a SINGLE document for archiving - from the Studio @@ -109,7 +110,7 @@ Learn more about modifying the metadata of a document in [Modifying Document Met E.g.: `"@archive-at": "2025-06-25T14:00:00.0000000Z"` 2. After saving the document, the Studio displays the time remaining until the document is archived. - +--- ## Schedule MULTIPLE documents for archiving - from the Client API @@ -128,8 +129,8 @@ Any document matching the query is then scheduled for archival by the **patch sc - -{`var archiveDate = SystemTime.UtcNow.AddDays(1); +```csharp +var archiveDate = SystemTime.UtcNow.AddDays(1); string archiveDateString = archiveDate.ToString("o"); var oldDate = SystemTime.UtcNow.AddYears(-1); @@ -153,12 +154,11 @@ var patchByQueryOp = new PatchByQueryOperation(patchByQuery); // Execute the operation by passing it to Operations.Send store.Operations.Send(patchByQueryOp); -`} - +``` - -{`var archiveDate = SystemTime.UtcNow.AddDays(1); +```csharp +var archiveDate = SystemTime.UtcNow.AddDays(1); string archiveDateString = archiveDate.ToString("o"); var oldDate = SystemTime.UtcNow.AddYears(-1); @@ -178,12 +178,11 @@ var patchByQueryOp = new PatchByQueryOperation(patchByQuery); // Execute the operation by passing it to Operations.SendAsync await store.Operations.SendAsync(patchByQueryOp); -`} - +``` - -{`var archiveDate = SystemTime.UtcNow.AddDays(1); +```csharp +var archiveDate = SystemTime.UtcNow.AddDays(1); string archiveDateString = archiveDate.ToString("o"); var oldDate = SystemTime.UtcNow.AddYears(-1); @@ -211,12 +210,11 @@ var patchByQueryOp = new PatchByQueryOperation(new IndexQuery() // Execute the operation by passing it to Operations.Send store.Operations.Send(patchByQueryOp); -`} - +``` - -{`var archiveDate = SystemTime.UtcNow.AddDays(1); +```csharp +var archiveDate = SystemTime.UtcNow.AddDays(1); string archiveDateString = archiveDate.ToString("o"); var oldDate = SystemTime.UtcNow.AddYears(-1); @@ -244,17 +242,16 @@ var patchByQueryOp = new PatchByQueryOperation(new IndexQuery() // Execute the operation by passing it to Operations.SendAsync await store.Operations.SendAsync(patchByQueryOp); -`} - +``` + **Syntax:** - -{`archived.archiveAt(doc, utcDateTimeString) -`} - +```csharp +archived.archiveAt(doc, utcDateTimeString) +``` | Parameter | Type | Description | @@ -264,7 +261,7 @@ await store.Operations.SendAsync(patchByQueryOp); To learn more about the `PatchByQueryOperation`, see [Set-based patch operations](../client-api/operations/patching/set-based.mdx). - +--- ## Schedule MULTIPLE documents for archiving - from the Studio @@ -286,8 +283,6 @@ performs the same operation as the [Client API example](../data-archival/schedul Learn more in [Test patch](../studio/database/documents/patch-view.mdx#test-patch). - - \ No newline at end of file +--> diff --git a/docs/data-archival/unarchiving-documents.mdx b/docs/data-archival/unarchiving-documents.mdx index acb9fa2e4e..993c7f0a96 100644 --- a/docs/data-archival/unarchiving-documents.mdx +++ b/docs/data-archival/unarchiving-documents.mdx @@ -2,7 +2,7 @@ title: "Unarchiving Documents" hide_table_of_contents: true sidebar_label: Unarchiving Documents -sidebar_position: 4 +sidebar_position: 5 --- import Admonition from '@theme/Admonition'; @@ -15,11 +15,11 @@ import LanguageContent from "@site/src/components/LanguageContent"; export const supportedLanguages = ["csharp"]; -# Unarchiving Documents +# Unarchiving Documents - + * Archived documents can be unarchived at any time. @@ -36,6 +36,9 @@ export const supportedLanguages = ["csharp"]; * [Unarchiving documents with index-based patch queries](../data-archival/unarchiving-documents.mdx#unarchiving-documents-with-index-based-patch-queries) + +--- + ## Unarchive documents - from the Client API * To unarchive documents from the Client API, use the `PatchByQueryOperation` operation, @@ -51,8 +54,8 @@ The following operation will unarchive ALL archived documents in the _Orders_ co - -{`// Define the patch query string +```csharp +// Define the patch query string string patchByQuery = @" // The patch query: // ================ @@ -69,12 +72,11 @@ var patchByQueryOp = new PatchByQueryOperation(patchByQuery); // Execute the operation by passing it to Operations.Send store.Operations.Send(patchByQueryOp); -`} - +``` - -{`// Define the patch query string +```csharp +// Define the patch query string string patchByQuery = @" from Orders update @@ -87,12 +89,11 @@ var patchByQueryOp = new PatchByQueryOperation(patchByQuery); // Execute the operation by passing it to Operations.Send await store.Operations.SendAsync(patchByQueryOp); -`} - +``` - -{`// Define the patch query string +```csharp +// Define the patch query string string patchByQuery = @" from Orders update @@ -108,12 +109,11 @@ var patchByQueryOp = new PatchByQueryOperation(new IndexQuery() // Execute the operation by passing it to Operations.Send store.Operations.Send(patchByQueryOp); -`} - +``` - -{`// Define the patch query string +```csharp +// Define the patch query string string patchByQuery = @" from Orders update @@ -129,24 +129,23 @@ var patchByQueryOp = new PatchByQueryOperation(new IndexQuery() // Execute the operation by passing it to Operations.Send await store.Operations.SendAsync(patchByQueryOp); -`} - +``` + **Syntax:** - -{`archived.unarchive(doc) -`} - +```csharp +archived.unarchive(doc) +``` | Parameter | Type | Description | |------------|----------|----------------------------| | **doc** | `object` | The document to unarchive. | - +--- ## Unarchive documents - from the Studio @@ -154,6 +153,7 @@ await store.Operations.SendAsync(patchByQueryOp); * Open the Patch view. * Enter a patch script that uses the `archived.unarchive()` method. * Execute the patch. + **Example**: The following patch script, used directly in the Studio, @@ -168,7 +168,7 @@ It will unarchive all archived documents in the _Orders_ collection. 4. You can test the patch on a sample document before executing the whole operation. Learn more in [Test patch](../studio/database/documents/patch-view.mdx#test-patch). - +--- ## Unarchiving documents with index-based patch queries @@ -185,21 +185,20 @@ It will unarchive all archived documents in the _Orders_ collection. and the patch operation will not unarchive any documents. - -{`string patchByQuery = @" +```csharp +string patchByQuery = @" // This filtering query creates an auto-index: // =========================================== from Orders where ShipTo.Country == 'USA' update - \{ + { archived.unarchive(this) - \}"; + }"; var patchByQueryOp = new PatchByQueryOperation(patchByQuery); store.Operations.Send(patchByQueryOp); -`} - +``` Two possible workarounds are: @@ -220,30 +219,26 @@ Two possible workarounds are: For example: - -{`string patchByQuery = @" +```csharp +string patchByQuery = @" // Perform a collection query: // =========================== from Orders as order update - \{ + { // Filter documents inside the script: // =================================== if (order.ShipTo.City == 'New York') - \{ + { archived.unarchive(this) - \} - \}"; + } + }"; var patchByQueryOp = new PatchByQueryOperation(patchByQuery); store.Operations.Send(patchByQueryOp); -`} - +``` - - - \ No newline at end of file +-->