---
title: currentDocument
description: >-
  Firestore pipelines currentDocument() expression helper: reference the
  document being processed, typically inside a select() stage.
next: /firestore/pipelines/if-null
previous: /firestore/pipelines
---
> ## Documentation Index
> Fetch the complete documentation index at: https://rnfirebase.io/llms.txt
> Use this file to discover all available pages before exploring further.

## Prerequisites

- `@react-native-firebase/app` installed and native config completed per [Getting Started](/).
- `@react-native-firebase/firestore` installed and rebuilt into the native app.
- A Firestore **Enterprise** database. See [Pipelines overview](/firestore/pipelines).
- Import expression helpers from `@react-native-firebase/firestore/pipelines`.

`currentDocument()` returns an [expression](/firestore/pipelines) representing the Firestore document row the pipeline is processing. Use it when you need the full document map in a projection or when binding the document to a variable in upstream firebase-js-sdk samples.

# Basic example

Read a field from the document map with `mapGet`:

```js
import { getFirestore } from '@react-native-firebase/firestore';
import {
  currentDocument,
  execute,
  field,
  mapGet,
} from '@react-native-firebase/firestore/pipelines';

const db = getFirestore('your-enterprise-database-id');

const snapshot = await execute(
  db
    .pipeline()
    .collection('books')
    .select(mapGet(currentDocument(), 'title').as('title'), field('author').as('author')),
);

snapshot.results.forEach(row => {
  console.log(row.data().title, row.data().author);
});
```

# Upstream define-stage pattern

The [firebase-js-sdk](https://firebase.google.com/docs/reference/js/firestore_pipelines#currentdocument) also shows binding the document with a `define` stage. React Native Firebase exposes the same `define` stage and `variable()` helper. Bind the document, then read fields with `mapGet(variable('doc'), 'fieldName')`. For a direct projection without a named binding, prefer `mapGet(currentDocument(), 'fieldName')` as in the Basic example above.

`currentDocument()` is typed as `Expression`, so the sample uses a JSDoc cast to `FunctionExpression` before calling `.as()`; `.as()` is not on every `Expression`.

```js
import { getFirestore } from '@react-native-firebase/firestore';
import {
  currentDocument,
  execute,
  mapGet,
  variable,
} from '@react-native-firebase/firestore/pipelines';

const firestore = getFirestore('your-enterprise-database-id');

const currentDoc =
  /** @type {import('@react-native-firebase/firestore/pipelines').FunctionExpression} */ (
    currentDocument()
  );

const snapshot = await execute(
  firestore
    .pipeline()
    .collection('books')
    .define(currentDoc.as('doc'))
    .select(mapGet(variable('doc'), 'title')),
);

snapshot.results.forEach(row => {
  console.log(row.data().title);
});
```

# Platform support

{/* prettier-ignore */}
| Platform | Support |
| --- | --- |
| Android | Supported (native Firestore SDK) |
| iOS | Supported (native Firestore SDK) |
| macOS | Supported (firebase-js-sdk web interop) |

Pipeline execution requires a Firestore **Enterprise** database. See [Pipelines overview](/firestore/pipelines).
