---
title: "Delete Document Command"
description: "Delete documents from RavenDB using the low-level DeleteDocumentCommand with optional change vector concurrency checks."
url: "https://docs.ravendb.net/7.2/client-api/commands/documents/delete"
version: "7.2"
language: "nodejs"
---

# Delete Document Command

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.md), [Java](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.java.md), [Python](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.python.md), [PHP](https://docs.ravendb.net/7.2/client-api/commands/documents/delete.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**
>
> - Use the low-level `DeleteDocumentCommand` to remove a document from the database.
>
> - To delete a document using a higher-level method, see [deleting entities](https://docs.ravendb.net/7.2/client-api/session/deleting-entities.nodejs.md).
>
> - In this page:
>
>   - [Examples](#examples)
>   - [Syntax](#syntax)

## Examples

> **Note**
>
> **Delete document command - using the Store's request executor**:
>
> ```javascript
> // Define the Delete Command
> // Pass the document ID & whether to make a concurrency check
> const command = new DeleteDocumentCommand("employees/1-A", null);
>
> // Send the command to the server using the Store's Request Executor
> await documentStore.getRequestExecutor().execute(command);
> ```

> **Note**
>
> **Delete document command - using the Session's request executor**:
>
> ```javascript
> const command = new DeleteDocumentCommand("employees/1-A", null);
>
> // Send the command to the server using the Session's Request Executor
> await session.advanced.requestExecutor.execute(command);
> ```

> **Note**
>
> **Delete document command - with concurrency check**:
>
> ```javascript
> // Load a document
> const employeeDocument = await session.load('employees/2-A');
> const cv = session.advanced.getChangeVectorFor(employeeDocument);
>
> // Modify the document content and save changes
> // The change-vector of the stored document will change
> employeeDocument.Title = "Some new title";
> await session.saveChanges();
>
> try  {
>   // Try to delete the document with the previous change-vector
>   const command = new DeleteDocumentCommand("employees/2-A", cv);
>   await session.advanced.requestExecutor.execute(command);
> }
> catch (err) {
>   // A concurrency exception is thrown 
>   // since the change-vector of the document in the database
>   // does not match the change-vector specified in the delete command
>   assert.equal(err.name, "ConcurrencyException");
> }
> ```

## Syntax

```javascript
DeleteDocumentCommand(id, changeVector);
```

| Parameter | Type | Description |
| - | - | - |
| **id** | `string` | The ID of the document to delete. |
| **changeVector** | `string` | The change-vector of the document you wish to delete,<br />used for [optimistic concurrency control](https://docs.ravendb.net/7.2/server/clustering/replication/change-vector.md#concurrency-control--change-vectors).<br />Pass `null` to skip the check and force the deletion. |

## See also

- [Get document](https://docs.ravendb.net/7.2/client-api/commands/documents/get.nodejs.md)
- [Put document](https://docs.ravendb.net/7.2/client-api/commands/documents/put.nodejs.md)
- [Send multiple commands using a batch](https://docs.ravendb.net/7.2/client-api/commands/batches/how-to-send-multiple-commands-using-a-batch.nodejs.md)
