---
title: "Conventions"
description: "Configure RavenDB client conventions to customize serialization, identity generation, load balancing, request handling, and cluster behavior."
url: "https://docs.ravendb.net/7.2/client-api/configuration/conventions"
version: "7.2"
language: "nodejs"
---

# Conventions

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/7.2/client-api/configuration/conventions.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**
>
> - **Conventions** in RavenDB are customizable settings that users can configure to tailor client behaviors according to their preferences.
>
> - In this article:
>   - [How to set conventions](#how-to-set-conventions)
>   - [Conventions:](#conventions:)  
>     [customFetch](#customfetch)  
>     [disableAtomicDocumentWritesInClusterWideTransaction](#disableatomicdocumentwritesinclusterwidetransaction)  
>     [disableTopologyUpdates](#disabletopologyupdates)  
>     [findCollectionName](#findcollectionname)  
>     [findJsType](#_findjstype)  
>     [findJsTypeName](#_findjstypename)  
>     [firstBroadcastAttemptTimeout](#firstbroadcastattempttimeout)  
>     [identityPartsSeparator](#identitypartsseparator)  
>     [loadBalanceBehavior](#loadbalancebehavior)  
>     [loadBalancerContextSeed](#loadbalancebehavior)  
>     [loadBalancerPerSessionContextSelector](#loadbalancebehavior)  
>     [maxHttpCacheSize](#maxhttpcachesize)  
>     [maxNumberOfRequestsPerSession](#maxnumberofrequestspersession)  
>     [readBalanceBehavior](#readbalancebehavior)  
>     [requestTimeout](#requesttimeout)  
>     [secondBroadcastAttemptTimeout](#secondbroadcastattempttimeout)  
>     [sendApplicationIdentifier](#sendapplicationidentifier)  
>     [shouldIgnoreEntityChanges](#shouldignoreentitychanges)  
>     [storeDatesInUtc](#storedatesinutc)  
>     [storeDatesWithTimezoneInfo](#storedateswithtimezoneinfo)  
>     [syncJsonParseLimit](#syncjsonparselimit)  
>     [throwIfQueryPageSizeIsNotSet](#throwifquerypagesizeisnotset)  
>     [transformClassCollectionNameToDocumentIdPrefix](#transformclasscollectionnametodocumentidprefix)  
>     [useCompression](#usecompression)  
>     [useJsonlStreaming](#usejsonlstreaming)  
>     [useOptimisticConcurrency](#useoptimisticconcurrency)  
>     [waitForIndexesAfterSaveChangesTimeout](#waitforindexesaftersavechangestimeout)  
>     [waitForNonStaleResultsTimeout](#waitfornonstaleresultstimeout)  
>     [waitForReplicationAfterSaveChangesTimeout](#waitforreplicationaftersavechangestimeout)

## How to set conventions

- Access the conventions via the `conventions` property of the `DocumentStore` object.

- The conventions set on a Document Store will apply to ALL [sessions](https://docs.ravendb.net/7.2/client-api/session/what-is-a-session-and-how-does-it-work.nodejs.md) and [operations](https://docs.ravendb.net/7.2/client-api/operations/what-are-operations.nodejs.md) associated with that store.

- Set the conventions **before** calling `documentStore.initialize()`.  
  Setting most conventions after calling `initialize()` throws an exception.

```javascript
const documentStore = new DocumentStore(["serverUrl_1", "serverUrl_2", "..."], "DefaultDB");

// Set conventions HERE, e.g.:
documentStore.conventions.maxNumberOfRequestsPerSession = 50;
documentStore.conventions.disableTopologyUpdates = true;

documentStore.initialize();

// * Here you can interact with the RavenDB store:
//   open sessions, create or query for documents, perform operations, etc.

// * Do not set conventions here, but before calling initialize()
```

## Conventions:

> **Note**
>
> #### customFetch
>
> - Use the `customFetch` convention to override the default *fetch* method.  
>   This method is useful to enable RavenDB Node.js client on CloudFlare Workers.
>
> - DEFAULT: undefined
>
> ```javascript
> // Returns an object
> get customFetch();
> // Set an object bound to worker with type: mtls_certificate
> set customFetch(customFetch);
> ```

> **Note**
>
> #### disableAtomicDocumentWritesInClusterWideTransaction
>
> - EXPERT ONLY:  
>   Use the `disableAtomicDocumentWritesInClusterWideTransaction` convention to disable automatic  
>   atomic writes with cluster write transactions.
>
> - When set to `true`, will only consider explicitly added compare exchange values to validate cluster wide transactions.
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean value
> get disableAtomicDocumentWritesInClusterWideTransaction();
> // Set a boolean value
> set disableAtomicDocumentWritesInClusterWideTransaction(
>   disableAtomicDocumentWritesInClusterWideTransaction
> );
> ```

> **Note**
>
> #### disableTopologyUpdates
>
> - When setting the `disableTopologyUpdates` convention to `true`,  
>   no database topology updates will be sent from the server to the client (e.g. adding or removing a node).
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean value
> get disableTopologyUpdates();
> // Set a boolean value
> set disableTopologyUpdates(value);
> ```

> **Note**
>
> #### findCollectionName
>
> - Use the `findCollectionName` convention to define a function that will customize the collection name  
>   from given type.
>
> - DEFAULT: The collection name will be the plural form of the type name.
>
> ```javascript
> // Returns a method
> get findCollectionName();
> // Set a method
> set findCollectionName(value);
> ```

> **Note**
>
> #### findJsType
>
> - Use the `findJsType` convention to define a function that finds the class of a document (if exists).
>
> - The type is retrieved from the `Raven-Node-Type` property under the `@metadata` key in the document.
>
> - DEFAULT: `null`
>
> ```javascript
> // Returns a method
> get findJsType();
> // Set a method
> set findJsType(value);
> ```

> **Note**
>
> #### findJsTypeName
>
> - Use the `findJsTypeName` convention to define a function that returns the class type name from a given type.
>
> - The class name will be stored in the entity metadata.
>
> - DEFAULT: `null`
>
> ```javascript
> // Returns a method
> get findJsTypeName();
> // Set a method
> set findJsTypeName(value);
> ```

> **Note**
>
> #### firstBroadcastAttemptTimeout
>
> - Use the `firstBroadcastAttemptTimeout` convention to set the timeout for the first broadcast attempt.
>
> - In the first attempt, the request executor will send a single request to the selected node.  
>   Learn about the "selected node" in: [Client logic for choosing a node](https://docs.ravendb.net/7.2/client-api/configuration/load-balance/overview.md#client-logic-for-choosing-a-node).
>
> - A [second attempt](#secondbroadcastattempttimeout) will be held upon failure.
>
> - DEFAULT: `5 seconds`
>
> ```javascript
> // Returns a number
> get firstBroadcastAttemptTimeout();
> // Set a number
> set firstBroadcastAttemptTimeout(firstBroadcastAttemptTimeout);
> ```

> **Note**
>
> #### identityPartsSeparator
>
> - Use the `identityPartsSeparator` convention to customize the **default ID separator** for document IDs generated automatically by the
>   [HiLo algorithm](https://docs.ravendb.net/7.2/client-api/document-identifiers/hilo-algorithm.md).
>
> - The value can be any char except `|` (pipe), which is reserved for identity IDs.
>
> - DEFAULT: `/` (forward slash)
>
> - Applies only to: [HiLo IDs](https://docs.ravendb.net/7.2/server/kb/document-identifier-generation.md#hilo-algorithm-id).
>
> ```javascript
> // Returns a string
> get identityPartsSeparator();
> // Set a string
> set identityPartsSeparator(value);
> ```

> **Note**
>
> #### loadBalanceBehavior
>
> #### loadBalancerPerSessionContextSelector
>
> #### loadBalancerContextSeed
>
> - Configure the **load balance behavior** by setting the following conventions:
>   - `loadBalanceBehavior`
>   - `loadBalancerPerSessionContextSelector`
>   - `loadBalancerContextSeed`
>
> - Learn more in the dedicated [Load balance behavior](https://docs.ravendb.net/7.2/client-api/configuration/load-balance/load-balance-behavior.nodejs.md) article.

> **Note**
>
> #### maxHttpCacheSize
>
> - Use the `MaxHttpCacheSize` convention to set the maximum HTTP cache size.  
>   This setting will affect all the databases accessed by the Document Store.
>
> - DEFAULT: `128 MB`
>
> - **Disabling Caching**:
>
>   - To disable caching globally, set `MaxHttpCacheSize` to zero.
>   - To disable caching per session, see: [Disable caching per session](https://docs.ravendb.net/7.2/client-api/session/configuration/how-to-disable-caching.nodejs.md).
>
> - Note: RavenDB also supports Aggressive Caching.  
>   Learn more about that in article [Setup aggressive caching](https://docs.ravendb.net/7.2/client-api/how-to/setup-aggressive-caching.md).
>
> ```javascript
> // Returns a number
> get maxHttpCacheSize();
> // Set a number
> set maxHttpCacheSize(value);
> ```

> **Note**
>
> #### maxNumberOfRequestsPerSession
>
> - Use the `maxNumberOfRequestsPerSession` convention to set the maximum number of requests per session.
>
> - DEFAULT: `30`
>
> ```javascript
> // Returns a number
> get maxNumberOfRequestsPerSession();
> // Set a number
> set maxNumberOfRequestsPerSession(value);
> ```

> **Note**
>
> #### readBalanceBehavior
>
> - Configure the **read request behavior** by setting the `readBalanceBehavior` convention.
>
> - Learn more in the dedicated [Read balance behavior](https://docs.ravendb.net/7.2/client-api/configuration/load-balance/read-balance-behavior.nodejs.md) article.

> **Note**
>
> #### requestTimeout
>
> - Use the `requestTimeout` convention to define the global request timeout value for all `RequestExecutors` created per database.
>
> - DEFAULT: `null` (the default HTTP client timout will be applied - 12h)
>
> ```javascript
> // Returns a number
> get requestTimeout();
> // Set a number
> set requestTimeout(value);
> ```

> **Note**
>
> #### secondBroadcastAttemptTimeout
>
> - Use the `secondBroadcastAttemptTimeout` convention to set the timeout for the second broadcast attempt.
>
> - Upon failure of the [first attempt](#firstbroadcastattempttimeout) the request executor will resend the command to all nodes simultaneously.
>
> - DEFAULT: `30 seconds`
>
> ```javascript
> // Returns a number
> get secondBroadcastAttemptTimeout();
> // Set a number
> set secondBroadcastAttemptTimeout(timeout);
> ```

> **Note**
>
> #### sendApplicationIdentifier
>
> - Use the `sendApplicationIdentifier` convention to `true` to enable sending a unique application identifier to the RavenDB Server.
>
> - Setting to *true* allows the server to issue performance hint notifications to the client,
>   e.g. during robust topology update requests which could indicate a Client API misuse impacting the overall performance.
>
> - DEFAULT: `true`
>
> ```javascript
> // Returns a boolean
> get sendApplicationIdentifier();
> // Set a boolean
> set sendApplicationIdentifier(sendApplicationIdentifier)
> ```

> **Note**
>
> #### shouldIgnoreEntityChanges
>
> - Set the `shouldIgnoreEntityChanges` convention to disable entity tracking for certain entities.
>
> - Learn more in [Customize tracking in conventions](https://docs.ravendb.net/7.2/client-api/session/configuration/how-to-disable-tracking.nodejs.md#customize-tracking-in-conventions).

> **Note**
>
> #### storeDatesInUtc
>
> - When setting the `storeDatesInUtc` convention to `true`,  
>   DateTime values will be stored in the database in UTC format.
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean
> get storeDatesInUtc();
> // Set a boolean
> set storeDatesInUtc(value);
> ```

> **Note**
>
> #### storeDatesWithTimezoneInfo
>
> - When setting the `storeDatesWithTimezoneInfo` to `true`,  
>   DateTime values will be stored in the database with their time zone information included.
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean
> get storeDatesWithTimezoneInfo();
> // Set a boolean
> set storeDatesWithTimezoneInfo(value);
> ```

> **Note**
>
> #### syncJsonParseLimit
>
> - Use the `syncJsonParseLimit` convention to define the maximum size for the *sync* parsing of the JSON data responses received from the server.  
>   For data exceeding this size, the client switches to *async* parsing.
>
> - DEFAULT: `2 * 1_024 * 1_024`
>
> ```javascript
> // Returns a number
> get syncJsonParseLimit();
> // Set a number
> set syncJsonParseLimit(value);
> ```

> **Note**
>
> #### throwIfQueryPageSizeIsNotSet
>
> - When setting the `throwIfQueryPageSizeIsNotSet` convention to `true`,  
>   an exception will be thrown if a query is performed without explicitly setting a page size.
>
> - This can be useful during development to identify potential performance bottlenecks
>   since there is no limitation on the number of results returned from the server.
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean
> get throwIfQueryPageSizeIsNotSet();
> // Set a boolean
> set throwIfQueryPageSizeIsNotSet(value);
> ```

> **Note**
>
> #### transformClassCollectionNameToDocumentIdPrefix
>
> - Use the `transformTypeCollectionNameToDocumentIdPrefix` convention to define a function that will  
>   customize the document ID prefix from the the collection name.
>
> - DEFAULT:  
>   By default, the document id prefix is determined as follows:
>
> | Number of uppercase letters in collection name | Document ID prefix |
> | - | - |
> | `<= 1` | Use the collection name with all lowercase letters |
> | `> 1` | Use the collection name as is, preserving the original case |
>
> ```javascript
> // Returns a method
> get transformClassCollectionNameToDocumentIdPrefix();
> // Set a method
> set transformClassCollectionNameToDocumentIdPrefix(value);
> ```

> **Note**
>
> #### useCompression
>
> - Set the `useCompression` convention to true in order to accept the **response** in compressed format and the automatic decompression of the HTTP response content.
>
> - A `Gzip` compression is always applied when sending content in an HTTP request.
>
> - DEFAULT: `true`
>
> ```javascript
> // Returns a boolean
> get useCompression();
> // Set a boolean
> set useCompression(value);
> ```

> **Note**
>
> #### useJsonlStreaming
>
> - Set the `useJsonlStreaming` convention to `true` when streaming query results as JSON Lines (JSONL) format.
>
> - DEFAULT: `true`
>
> ```javascript
> // Returns a boolean
> get useJsonlStreaming();
> // Set a boolean
> set useJsonlStreaming(value);
> ```

> **Note**
>
> #### useOptimisticConcurrency
>
> - When setting the `useOptimisticConcurrency` convention to `true`,  
>   Optimistic Concurrency checks will be applied for all sessions opened from the Document Store.
>
> - Learn more about Optimistic Concurrency and the various ways to enable it in article  
>   [how to enable optimistic concurrency](https://docs.ravendb.net/7.2/client-api/session/configuration/how-to-enable-optimistic-concurrency.nodejs.md).
>
> - DEFAULT: `false`
>
> ```javascript
> // Returns a boolean
> get useOptimisticConcurrency();
> // Set a boolean
> set useOptimisticConcurrency(value);
> ```

> **Note**
>
> #### waitForIndexesAfterSaveChangesTimeout
>
> - Use the `waitForIndexesAfterSaveChangesTimeout` convention to set the default timeout for the
>   `documentSession.advanced.waitForIndexesAfterSaveChanges` method.
>
> - DEFAULT: 15 Seconds
>
> ```javascript
> // Returns a number
> get waitForIndexesAfterSaveChangesTimeout();
> // Set a number
> set waitForIndexesAfterSaveChangesTimeout(value);
> ```

> **Note**
>
> #### waitForNonStaleResultsTimeout
>
> - Use the `waitForNonStaleResultsTimeout` convention to set the default timeout used by the  
>   `waitForNonStaleResults` method when querying.
>
> - DEFAULT: 15 Seconds
>
> ```javascript
> // Returns a number
> get waitForNonStaleResultsTimeout();
> // Set a number
> set waitForNonStaleResultsTimeout(value);
> ```

> **Note**
>
> #### waitForReplicationAfterSaveChangesTimeout
>
> - Use the `waitForReplicationAfterSaveChangesTimeout` convention to set the default timeout for the  
>   `documentSession.advanced.waitForReplicationAfterSaveChanges`method.
>
> - DEFAULT: 15 Seconds
>
> ```javascript
> // Returns a number
> get waitForReplicationAfterSaveChangesTimeout();
> // Set a number
> set waitForReplicationAfterSaveChangesTimeout(value);
> ```

## See also

- [Querying](https://docs.ravendb.net/7.2/querying/customize-query.nodejs.md)
- [Serialization](https://docs.ravendb.net/7.2/client-api/configuration/serialization.md)
- [Load Balancing Client Requests](https://docs.ravendb.net/7.2/client-api/configuration/load-balance/overview.md)
- [Working with Document Identifiers](https://docs.ravendb.net/7.2/client-api/document-identifiers/working-with-document-identifiers.md)
- [Global ID Generation Conventions](https://docs.ravendb.net/7.2/client-api/configuration/identifier-generation/global.nodejs.md)
- [Type-specific ID Generation Conventions](https://docs.ravendb.net/7.2/client-api/configuration/identifier-generation/type-specific.nodejs.md)
- [What is a Document Store](https://docs.ravendb.net/7.2/client-api/what-is-a-document-store.nodejs.md)
