---
title: "Adding a Database Node"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node"
version: "6.2"
language: "nodejs"
---

# Adding a Database Node

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.md), [Python](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/server-wide/add-database-node.php.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**
>
> - When creating a database, you can specify the number of replicas for that database.  
>   This determines the number of database instances in the database-group.
>
> - **The number of replicas can be dynamically increased** even after the database is up and running,  
>   by adding more nodes to the database-group.
>
> - The nodes added must already exist in the [cluster topology](https://docs.ravendb.net/6.2/server/clustering/rachis/cluster-topology.md).
>
> - Once a new node is added to the database-group,  
>   the cluster assigns a mentor node (from the existing database-group nodes) to update the new node.
>
> - In this page:
>   - [Add database node - random](#add-database-node---random)
>   - [Add database node - specific](#add-database-node---specific)
>   - [Syntax](#syntax)

## Add database node - random

- Use `AddDatabaseNodeOperation` to add another database-instance to the database-group.
- The node added will be a random node from the existing cluster nodes.

```javascript
// Create the AddDatabaseNodeOperation
// Add a random node to 'Northwind' database-group
const addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind");

// Execute the operation by passing it to maintenance.server.send
const result = await documentStore.maintenance.server.send(addDatabaseNodeOp);

// Can access the new topology
const numberOfReplicas = getAllNodesFromTopology(result.topology).length;
```

## Add database node - specific

- You can specify the node tag to add.
- This node must already exist in the cluster topology.

```javascript
// Create the AddDatabaseNodeOperation
// Add node C to 'Northwind' database-group
const addDatabaseNodeOp = new AddDatabaseNodeOperation("Northwind", "C"));

// Execute the operation by passing it to maintenance.server.send
const result = await documentStore.maintenance.server.send(addDatabaseNodeOp);
```

## Syntax

```javascript
const addDatabaseNodeOp = new AddDatabaseNodeOperation(databaseName, nodeTag?);
```

| Parameters | Type | Description |
| - | - | - |
| **databaseName** | `string` | Name of a database for which to add the node. |
| **nodeTag** | `string` | Tag of node to add.<br />Default: If not passed then a random node from the existing cluster topology will be added. |

| Object returned by send operation has: | Type | Description |
| - | - | - |
| raftCommandIndex | `number` | Index of the raft command that was executed |
| name | `string` | Database name |
| topology | `DatabaseTopology` | The database topology |
| nodesAddedTo | `string[]` | New nodes added to the cluster topology.<br />Will be 0 for this operation. |
