---
title: "Enforce Revisions Configuration Operation"
description: "Apply the current revisions configuration to all existing revisions using the EnforceRevisionsConfigurationOperation, with optional throttling via MaxOpsPerSecond."
url: "https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration"
version: "7.2"
language: "nodejs"
---

# Enforce Revisions Configuration Operation

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

> **Note**
>
> - The revision configuration rules are usually applied to a document's revisions only when the document is modified.  
>   Use `EnforceRevisionsConfigurationOperation` to apply the current [revisions configuration](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md)
>   to existing revisions, instead of waiting for each document to be modified.
>
> - Running this operation scans existing revisions and enforces the current rules immediately,
>   **deleting** eligible revisions that should be purged according to the configuration.
>
> - The operation can be applied to all collections (default) or to a specified set of collections.
>
> - By default, the operation is applied to the [default database](https://docs.ravendb.net/7.2/client-api/setting-up-default-database.nodejs.md).  
>   To operate on a different database, see [switch operations to a different database](https://docs.ravendb.net/7.2/client-api/operations/how-to/switch-operations-to-a-different-database.nodejs.md).
>
> - This article explains how to run the operation from the Client API.  
>   To run it from Studio, see [Enforce configuration](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md#enforce-configuration) in the Document Revisions settings view.
>
> - In this article:
>   - [Enforce configuration on all collections](#enforce-configuration-on-all-collections)
>   - [Enforce configuration on specific collections](#enforce-configuration-on-specific-collections)
>   - [Include force-created revisions](#include-force-created-revisions)
>   - [Throttle the operation](#throttle-the-operation)
>   - [Syntax](#syntax)

> **Warning:** Resource consumption
>
> - Large databases may contain many revisions that will be deleted when the current configuration is enforced.  
>   Running the operation can delete them all in a single enforcement run and may require substantial server resources.
>   Schedule it accordingly.
>
> - On large datasets, use `maxOpsPerSecond` to [throttle the operation](#throttle-the-operation)
>   and reduce its resource consumption.
>
> - Revisions in collections that no current configuration applies to may be deleted.
>   Make sure your revisions configuration includes the default settings and collection-specific configurations needed to keep the revisions you want to preserve.
>   Force-created revisions may also be removed when `includeForceCreated` is set to `true`.

## Enforce configuration on all collections {#enforce-configuration-on-all-collections}

In this example, the current revisions configuration is enforced on the revisions of all collections.

```javascript
// Define the enforce revisions configuration operation
const enforceConfigurationOp = new EnforceRevisionsConfigurationOperation();

// Execute the operation by passing it to operations.send
// 'send' returns the operation id result: { operationId, operationNodeTag }
const operationIdResult = await documentStore.operations.send(enforceConfigurationOp);
```

## Enforce configuration on specific collections {#enforce-configuration-on-specific-collections}

Set the `collections` parameter to enforce the configuration only on revisions in the specified collections.  
When `collections` is not set, is `null`, or is an empty array, the operation is applied to all collections.

```javascript
const enforceConfigurationOp = new EnforceRevisionsConfigurationOperation({
    includeForceCreated: false,
    // The configuration will be enforced only on these collections
    collections: ["Users", "Products"]
});

const operationIdResult = await documentStore.operations.send(enforceConfigurationOp);
```

## Include force-created revisions {#include-force-created-revisions}

By default, [force-created revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.nodejs.md#force-revision-creation)
are preserved and are not removed by the operation.

Set `includeForceCreated` to `true` to allow those force-created revisions to be removed as well.

```javascript
const enforceConfigurationOp = new EnforceRevisionsConfigurationOperation({
    // Force-created revisions will also be subject to the configuration rules
    includeForceCreated: true
});

const operationIdResult = await documentStore.operations.send(enforceConfigurationOp);
```

## Throttle the operation {#throttle-the-operation}

Running the operation on a large database may consume substantial server resources and affect server performance.

Set `maxOpsPerSecond` to limit the number of documents processed per second,  
throttling the operation to reduce its resource consumption.

```javascript
const enforceConfigurationOp = new EnforceRevisionsConfigurationOperation({
    includeForceCreated: false,
    // Process at most 100 documents per second
    maxOpsPerSecond: 100
});

const operationIdResult = await documentStore.operations.send(enforceConfigurationOp);
```

> **Warning**
>
> `maxOpsPerSecond` must be greater than `0`.  
> Setting it to `0` or a negative value throws an `InvalidOperationException`.

## Syntax {#syntax}

```javascript
// Available overloads:
// ====================

// Enforce the configuration using default parameters (all collections)
new EnforceRevisionsConfigurationOperation();

// Enforce the configuration using the specified parameters
new EnforceRevisionsConfigurationOperation(parameters);
```

| Parameter | Type | Description |
| - | - | - |
| **parameters** | `EnforceRevisionsParameters` | The parameters defining how the configuration is enforced. See the interface below. |

```javascript
interface EnforceRevisionsParameters {
    includeForceCreated: boolean; // required when passing parameters
    collections?: string[];
    maxOpsPerSecond?: number;
}
```

| Parameter | Type | Description |
| - | - | - |
| **includeForceCreated** | `boolean` | **Required when passing a parameters object** (the no-argument constructor defaults it to `false`).<br />`true` - [Force-created revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.nodejs.md#force-revision-creation) may also be removed by the operation.<br />`false` - Force-created revisions are not included in deletion paths that explicitly protect them. |
| **collections** | `string[]` | The collections the operation applies to.<br />When omitted or `null`, the operation applies to all collections. |
| **maxOpsPerSecond** | `number` | Limits the number of documents processed per second, throttling the operation to reduce resource consumption.<br />When omitted, no throttling is applied.<br />Must be greater than `0`, otherwise an `InvalidOperationException` is thrown. |

> **Note**
>
> `includeForceCreated` is a **required** field of `EnforceRevisionsParameters`.  
> When you pass a parameters object you must set it explicitly (usually to `false`).  
> To rely on its default value (`false`), call the no-argument constructor instead:  
> `new EnforceRevisionsConfigurationOperation()`.

The `send` method returns an `OperationIdResult` object:

```javascript
interface OperationIdResult {
    operationId: number;
    operationNodeTag: string;
}
```

## See also

- [Revisions Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.nodejs.md)
- [Delete Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/delete-revisions.md)
- [Revert Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.md)
- [Revisions and Other Features](https://docs.ravendb.net/7.2/document-extensions/revisions/revisions-and-other-features.nodejs.md)
- [Revisions: API Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/overview.nodejs.md)
- [Session: Loading Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/loading.nodejs.md)
- [Session: Including Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/including.nodejs.md)
- [Session: Counting Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/counting.nodejs.md)
- [What Are Operations](https://docs.ravendb.net/7.2/client-api/operations/what-are-operations.nodejs.md)
- [Switch Operation Database](https://docs.ravendb.net/7.2/client-api/operations/how-to/switch-operations-to-a-different-database.nodejs.md)
- [Settings: Document Revisions](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md)
- [Document Extensions: Revisions](https://docs.ravendb.net/7.2/studio/database/document-extensions/revisions/revisions-overview.md)
