---
title: "Client API: Setting up a Default Database"
url: "https://docs.ravendb.net/6.2/client-api/setting-up-default-database"
version: "6.2"
language: "nodejs"
---

# Client API: Setting up a Default Database

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.md), [Java](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.java.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."

`database` property allows you to setup a default database for a `DocumentStore`. Implication of setting up a default database is that each time you access [operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.nodejs.md) or create a [session](https://docs.ravendb.net/6.2/client-api/session/what-is-a-session-and-how-does-it-work.nodejs.md) without explicitly passing database on which they should operate on then default database is assumed.

## Example I

```javascript
// without specifying `database`
// we will need to specify the database in each action
// if no database is passed explicitly we will get an error

const store = new DocumentStore([ "http://localhost:8080" ]);
store.initialize();

{
  const session = store.openSession("Northwind");
  // ...
}

const compactSettings = { databaseName: "Northwind" };
await store.maintenance.server.send(
  new CompactDatabaseOperation(compactSettings));
```

## Example II

```javascript
// when `database` is set to `Northwind`
// created `operations` or opened `sessions`
// will work on `Northwind` database by default
// if no database is passed explicitly
const store =  new DocumentStore("http://localhost:8080", "Northwind");
store.initialize();

{
  const northwindSession = store.openSession();
  // ...
}

await store.maintenance.send(
  new DeleteIndexOperation("NorthwindIndex"));

{
  const adventureWorksSession = store.openSession("AdventureWorks");
  // ...
}

await store.maintenance.forDatabase("AdventureWorks")
  .send(new DeleteIndexOperation("AdventureWorksIndex"));
```

## Remarks

> **Note**
>
> By default value of `database` property in `DocumentStore` is `null` which means that in any action requiring a database name, we will have to specify the database.

## See also

- [What is a Document Store](https://docs.ravendb.net/6.2/client-api/what-is-a-document-store.nodejs.md)
- [Creating a Document Store](https://docs.ravendb.net/6.2/client-api/creating-document-store.nodejs.md)
- [Setting up Authentication and Authorization](https://docs.ravendb.net/6.2/client-api/setting-up-authentication-and-authorization.nodejs.md)
- [Creating a Database](https://docs.ravendb.net/6.2/studio/database/create-new-database/general-flow.md)
