---
title: "Get a Per-Database Connection String"
url: "https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/get-connection-strings"
version: "7.2"
language: "nodejs"
---

# Get a Per-Database Connection String

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/get-connection-strings.md), [Java](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/get-connection-strings.java.md), [Python](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/get-connection-strings.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**
>
> - Use `GetConnectionStringsOperation` to retrieve a specific connection string,  
>   or all connection strings defined in the database.
>
> - This operation reads connection strings from a single database's record.  
>   To get connection strings defined at the cluster level, see [Get server-wide connection strings](https://docs.ravendb.net/7.2/integrations/connection-strings/server-wide/get-connection-strings.md).
>
> - Learn more about per-database connection strings in [Per-database connection strings - Overview](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/overview.md).  
>   To create or update a connection string, see [Add or update a connection string](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/add-or-update-connection-string.nodejs.md).
>
> - In this article:
>   - [Get connection string by name and type](#get-connection-string-by-name-and-type)
>   - [Get all connection strings](#get-all-connection-strings)
>   - [Syntax](#syntax)

## Get connection string by name and type {#get-connection-string-by-name-and-type}

The following example retrieves a `Raven` connection string in the current database:

```javascript
// Request a specific connection string, pass its name and type:
// =============================================================
const getRavenConStrOp = new GetConnectionStringsOperation(
    "ravendb-connection-string-name", "Raven");

const connectionStrings = await store.maintenance.send(getRavenConStrOp);

// Access results:
// ===============
const ravenConnectionStrings = connectionStrings.ravenConnectionStrings;

// If no connection string matches the specified name and type, 
// the result object is null.
if (ravenConnectionStrings) {
    const numberOfRavenConnectionStrings = Object.keys(ravenConnectionStrings).length;
    const ravenConStr = ravenConnectionStrings["ravendb-connection-string-name"];

    const targetUrls = ravenConStr.topologyDiscoveryUrls;
    const targetDatabase = ravenConStr.database;
}
```

## Get all connection strings {#get-all-connection-strings}

The following example retrieves all connection strings defined in the database:

```javascript
// Get all connection strings:
// ===========================
const getAllConStrOp = new GetConnectionStringsOperation();
const allConnectionStrings = await store.maintenance.send(getAllConStrOp);

// Access results by connection string type:
// =========================================

// Raven
const ravenConnectionStrings = allConnectionStrings.ravenConnectionStrings;

// SQL
const sqlConnectionStrings = allConnectionStrings.sqlConnectionStrings;

// OLAP
const olapConnectionStrings = allConnectionStrings.olapConnectionStrings;

// Elasticsearch
const elasticsearchConnectionStrings = allConnectionStrings.elasticSearchConnectionStrings;

// Queue
const queueConnectionStrings = allConnectionStrings.queueConnectionStrings;

// AI
const aiConnectionStrings = allConnectionStrings.aiConnectionStrings;
```

## Syntax {#syntax}

```javascript
new GetConnectionStringsOperation();
new GetConnectionStringsOperation(connectionStringName, type);
```

| Parameter | Type | Description |
| - | - | - |
| **connectionStringName** | `string` | Connection string name |
| **type** | `ConnectionStringType` | Connection string type:<br />`Raven`, `Sql`, `Olap`, `ElasticSearch`, `Queue`, or `Ai` |

```javascript
// The available connection string types
ConnectionStringType = "None" | "Raven" | "Sql" | "Olap" | "ElasticSearch" | "Queue" | "Ai";
```

| Operation result | Description |
| - | - |
| `GetConnectionStringsResult` | Object holding all connection strings defined in the database. |

```javascript
interface GetConnectionStringsResult {
    ravenConnectionStrings; // Record<string, RavenConnectionString>
    sqlConnectionStrings; // Record<string, SqlConnectionString>
    olapConnectionStrings; // Record<string, OlapConnectionString>
    elasticSearchConnectionStrings; // Record<string, ElasticSearchConnectionString>
    queueConnectionStrings; // Record<string, QueueConnectionString>
    aiConnectionStrings; // Record<string, AiConnectionString>
}
```

> **Note**
>
> The Node.js client returns connection strings of the `Raven`, `Sql`, `Olap`, `ElasticSearch`, `Queue`
> (Kafka and RabbitMQ), and `Ai` types.  
> Connection string types that have no matching class in the Node.js client, such as `Snowflake`, can be viewed from Studio.

> **Note**
>
> Connection string type-specific fields and complete examples are documented in the task or feature articles listed under
> [Connection string per type](https://docs.ravendb.net/7.2/integrations/connection-strings/per-database/add-or-update-connection-string.nodejs.md#connection-string-per-type).
