---
title: "Get Revisions"
url: "https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading"
version: "6.2"
language: "nodejs"
---

# Get Revisions

> Client language: Node.js. Also available for [C#](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.md), [Java](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.java.md), [Python](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.python.md), [PHP](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.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**
>
> - Using the Advanced Session methods you can **retrieve revisions and their metadata**  
>   from the database for the specified document.
>
> - These methods can also be executed lazily, see [get revisions lazily](https://docs.ravendb.net/6.2/client-api/session/how-to/perform-operations-lazily.nodejs.md#getrevisions).
>
> - In this page:
>   - [Get all revisions](#get-all-revisions)
>   - [Get revisions metadata](#get-revisions-metadata)
>   - [Get revisions by creation time](#get-revisions-by-creation-time)
>   - [Get revisions by change vector](#get-revisions-by-change-vector)

## Get all revisions

- Use `getFor` to retrieve all of the revisions currently kept for the specified document.
  **Example**:

```javascript
// Get revisions for document 'orders/1-A'
const orderRevisions = await session.advanced.revisions
  .getFor("orders/1-A", {
      start: 0,
      pageSize: 10
  });
```

**Syntax**:

```javascript
// Available overloads:
await session.advanced.revisions.getFor(id);
await session.advanced.revisions.getFor(id, options);
```

| Parameters | Type | Description |
| - | - | - |
| **id** | string | Document ID for which to retrieve revisions |
| **options** | options object | Used for paging |

```javascript
// options object
{
  start,   // The first revision to retrieve, used for paging. Default is 0.
  pageSize // Number of revisions to retrieve per results page. Default is 25.
}
```

| Return value | |
| - | - |
| `Promise` | A `Promise` resolving to the document's revisions. <br />Revisions will be ordered by most recent revision first. |

## Get revisions metadata

- Use `getMetadataFor` to retrieve the metadata for all the revisions currently kept for the specified document.
  **Example**:

```javascript
// Get revisions' metadata for document 'orders/1-A'
const orderRevisionsMetadata = await session.advanced.revisions
  .getMetadataFor("orders/1-A", {
      start: 0,
      pageSize: 10
  });

// Each item returned is a revision's metadata, as can be verified in the @flags key
const metadata = orderRevisionsMetadata[0];
const flagsValue = metadata[CONSTANTS.Documents.Metadata.FLAGS];

assertThat(flagsValue).contains("Revision");
```

**Syntax**:

```javascript
// Available overloads:
await session.advanced.revisions.getMetadataFor(id);
await session.advanced.revisions.getMetadataFor(id, options);
```

| Parameters | Type | Description |
| - | - | - |
| **id** | string | Document ID for which to retrieve revisions' metadata |
| **options** | options object | Used for paging |

```javascript
// options object
{
  start,   // The first revision to retrieve, used for paging. Default is 0.
  pageSize // Number of revisions to retrieve per results page. Default is 25.
}
```

| Return value | |
| - | - |
| `Promise` | A `Promise` resolving to a list of the revisions metadata. |

## Get revisions by creation time

- Use `get` to retrieve a revision by its **creation time**.
  **Example**:

```javascript
// Creation time to use, e.g. last year: 
const creationTime = new Date();
creationTime.setFullYear(creationTime.getFullYear() - 1);

// Get a revision by its creation time
// If no revision was created at the specified time,
// then the first revision that precedes it will be returned
const orderRevision = await session.advanced.revisions
  .get("orders/1-A", creationTime.toLocaleDateString());
```

**Syntax**:

```javascript
await session.advanced.revisions.get(id, date);
```

| Parameter | Type | Description |
| - | - | - |
| **id** | string | Document ID for which to retrieve the revision by creation time |
| **date** | string | The revision's creation time |

| Return value | |
| - | - |
| `Promise` | A `Promise` resolving to the revision.<br />If no revision was created at the specified time, then the first revision that precedes it will be returned. |

## Get revisions by change vector

- Use `get` to retrieve a revision or multiple revisions by their **change vectors**.
  **Example**:

```javascript
// Get revisions metadata 
const revisionsMetadata = await session.advanced.revisions
  .getMetadataFor("orders/1-A", {
      start: 0,
      pageSize: 25
  });

// Get the change-vector from the metadata
var changeVector = revisionsMetadata[0][CONSTANTS.Documents.Metadata.CHANGE_VECTOR];

// Get the revision by its change-vector
const orderRevision = await session.advanced.revisions
  .get(changeVector);
```

**Syntax**:

```javascript
// Available overloads:
await session.advanced.revisions.get(changeVector);
await session.advanced.revisions.get(changeVectors);
```

| Parameter | Type | Description |
| - | - | - |
| **changeVector** | string | The revision's change vector |
| **changeVectors** | string\[] | Change vectors of multiple revisions |

| Return value | |
| - | - |
| `Promise` | A `Promise` resolving to the matching revision(s). |

## See also

- [Document Revisions Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/overview.nodejs.md)
- [Revert Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.md)
- [Revisions and Other Features](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.nodejs.md)
- [Revisions: API Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/overview.nodejs.md)
- [Operations: Configuring Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/operations/configure-revisions.nodejs.md)
- [Session: Including Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/including.nodejs.md)
- [Session: Counting Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/counting.nodejs.md)
- [Settings: Document Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
- [Document Extensions: Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
