<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Aggregation Stages
  <a class="headerlink leafygreen-ui-1kepx47" href="#aggregation-stages" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="aggregation-stages">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#compatibility" target="_self">
     <span>
      Compatibility
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#db.collection.aggregate---stages" target="_self">
     <span>
      db.collection.aggregate() Stages
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#db.aggregate---stages" target="_self">
     <span>
      db.aggregate() Stages
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#stages-available-for-updates" target="_self">
     <span>
      Stages Available for Updates
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  In the
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.aggregate/#mongodb-method-db.collection.aggregate">
   <code class="leafygreen-ui-1l06pbn">
    db.collection.aggregate()
   </code>
  </a>
  method and
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.aggregate/#mongodb-method-db.aggregate">
   <code class="leafygreen-ui-1l06pbn">
    db.aggregate()
   </code>
  </a>
  method,
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline">
   pipeline
  </a>
  stages appear in an array. In the Atlas UI, you can arrange pipeline
stages using the
  <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-ui/agg-pipeline/#std-label-atlas-ui-agg-pipeline" target="_self">
   <span>
    aggregation pipeline builder
   </span>
  </a>
  . Documents pass
through the stages in sequence.
 </p>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Compatibility
   <a class="headerlink leafygreen-ui-1kepx47" href="#compatibility" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="compatibility">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   You can use
   <!-- -->
   pipeline stages
   <!-- -->
   for deployments hosted in the following
environments:
  </p>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas?tck=docs_server" target="_self">
      <span>
       MongoDB Atlas
      </span>
     </a>
     : The fully
managed service for MongoDB deployments in the cloud
    </p>
   </li>
  </ul>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/install-enterprise/#std-label-install-mdb-enterprise">
      MongoDB Enterprise
     </a>
     : The
subscription-based, self-managed version of MongoDB
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/administration/install-community/#std-label-install-mdb-community-edition">
      MongoDB Community
     </a>
     : The
source-available, free-to-use, and self-managed version of MongoDB
    </p>
   </li>
  </ul>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   db.collection.aggregate() Stages
   <a class="headerlink leafygreen-ui-1kepx47" href="#db.collection.aggregate---stages" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="db.collection.aggregate---stages">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   All stages except the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
    <code class="leafygreen-ui-1l06pbn">
     $out
    </code>
   </a>
   ,
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge">
    <code class="leafygreen-ui-1l06pbn">
     $merge
    </code>
   </a>
   ,
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear">
    <code class="leafygreen-ui-1l06pbn">
     $geoNear
    </code>
   </a>
   ,
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStream/#mongodb-pipeline-pipe.-changeStream">
    <code class="leafygreen-ui-1l06pbn">
     $changeStream
    </code>
   </a>
   , and
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#mongodb-pipeline-pipe.-changeStreamSplitLargeEvent">
    <code class="leafygreen-ui-1l06pbn">
     $changeStreamSplitLargeEvent
    </code>
   </a>
   stages can appear multiple
times in a pipeline.
  </p>
  <div class="leafygreen-ui-15mdk4" role="note">
   <h2 class="leafygreen-ui-6n7b7d">
    Note
   </h2>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     For details on a specific operator, including syntax and examples,
click on the link to the operator's reference page.
    </p>
   </div>
  </div>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.collection.aggregate( [ { &lt;stage&gt; }, ... ] )","programmingLanguage":"JavaScript"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-1q4bxgx" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">collection</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ &lt;<!-- -->stage<!-- -->&gt; <!-- -->}<!-- -->, <!-- -->...<!-- --> ] )</td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:20%"/>
     <col style="width:80%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Stage
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Description
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
          <code class="leafygreen-ui-1l06pbn">
           $addFields
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Adds new fields to documents. Similar to
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
           <code class="leafygreen-ui-1l06pbn">
            $project
           </code>
          </a>
          ,
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
           <code class="leafygreen-ui-1l06pbn">
            $addFields
           </code>
          </a>
          reshapes each
document in the stream; specifically, by adding new fields to
output documents that contain both the existing fields
from the input documents and the newly added fields.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set">
           <code class="leafygreen-ui-1l06pbn">
            $set
           </code>
          </a>
          is an alias for
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
           <code class="leafygreen-ui-1l06pbn">
            $addFields
           </code>
           .
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/bucket/#mongodb-pipeline-pipe.-bucket">
          <code class="leafygreen-ui-1l06pbn">
           $bucket
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Categorizes incoming documents into groups, called buckets,
based on a specified expression and bucket boundaries.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/bucketAuto/#mongodb-pipeline-pipe.-bucketAuto">
          <code class="leafygreen-ui-1l06pbn">
           $bucketAuto
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Categorizes incoming documents into a specific number of
groups, called buckets, based on a specified expression.
Bucket boundaries are automatically determined in an attempt
to evenly distribute the documents into the specified number
of buckets.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStream/#mongodb-pipeline-pipe.-changeStream">
          <code class="leafygreen-ui-1l06pbn">
           $changeStream
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns a
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams">
          Change Stream
         </a>
         cursor for the
collection.  This stage can only occur once in an aggregation
pipeline and it must occur as the first stage.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/#mongodb-pipeline-pipe.-changeStreamSplitLargeEvent">
          <code class="leafygreen-ui-1l06pbn">
           $changeStreamSplitLargeEvent
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Splits large
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams">
           change stream
          </a>
          events that exceed 16
MB into smaller fragments returned in a change stream cursor.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          You can only use
          <code class="leafygreen-ui-1l06pbn">
           $changeStreamSplitLargeEvent
          </code>
          in a
          <code class="leafygreen-ui-1l06pbn">
           $changeStream
          </code>
          pipeline and it must be the final stage in the pipeline.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/collStats/#mongodb-pipeline-pipe.-collStats">
          <code class="leafygreen-ui-1l06pbn">
           $collStats
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns statistics regarding a collection or view.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/count/#mongodb-pipeline-pipe.-count">
          <code class="leafygreen-ui-1l06pbn">
           $count
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns a count of the number of documents at this stage of
the aggregation pipeline.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          Distinct from the
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/count-accumulator/#mongodb-group-grp.-count">
           <code class="leafygreen-ui-1l06pbn">
            $count
           </code>
          </a>
          aggregation accumulator.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/densify/#mongodb-pipeline-pipe.-densify">
          <code class="leafygreen-ui-1l06pbn">
           $densify
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Creates new documents in a sequence of documents where certain values
in a field are missing.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/documents/#mongodb-pipeline-pipe.-documents">
          <code class="leafygreen-ui-1l06pbn">
           $documents
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns literal documents from input expressions.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/facet/#mongodb-pipeline-pipe.-facet">
          <code class="leafygreen-ui-1l06pbn">
           $facet
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Processes multiple
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline">
          aggregation pipelines
         </a>
         within a single stage on the same set
of input documents. Enables the creation of multi-faceted
aggregations capable of characterizing data across multiple
dimensions, or facets, in a single stage.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/fill/#mongodb-pipeline-pipe.-fill">
          <code class="leafygreen-ui-1l06pbn">
           $fill
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Populates
          <code class="leafygreen-ui-1l06pbn">
           null
          </code>
          and missing field values within documents.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/geoNear/#mongodb-pipeline-pipe.-geoNear">
          <code class="leafygreen-ui-1l06pbn">
           $geoNear
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns an ordered stream of documents based on the proximity to a
geospatial point. Incorporates the functionality of
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match">
           <code class="leafygreen-ui-1l06pbn">
            $match
           </code>
          </a>
          ,
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort">
           <code class="leafygreen-ui-1l06pbn">
            $sort
           </code>
          </a>
          , and
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/limit/#mongodb-pipeline-pipe.-limit">
           <code class="leafygreen-ui-1l06pbn">
            $limit
           </code>
          </a>
          for
geospatial data. The output documents include an additional distance
field and can include a location identifier field.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/graphLookup/#mongodb-pipeline-pipe.-graphLookup">
          <code class="leafygreen-ui-1l06pbn">
           $graphLookup
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Performs a recursive search on a collection. To each output
document, adds a new array field that contains the traversal
results of the recursive search for that document.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/group/#mongodb-pipeline-pipe.-group">
          <code class="leafygreen-ui-1l06pbn">
           $group
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Groups input documents by a specified identifier expression
and applies the accumulator expression(s), if specified, to
each group. Consumes all input documents and outputs one
document per each distinct group. The output documents only
contain the identifier field and, if specified, accumulated
fields.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/indexStats/#mongodb-pipeline-pipe.-indexStats">
          <code class="leafygreen-ui-1l06pbn">
           $indexStats
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns statistics regarding the use of each index for the
collection.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/limit/#mongodb-pipeline-pipe.-limit">
          <code class="leafygreen-ui-1l06pbn">
           $limit
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Passes the first
         <em>
          n
         </em>
         documents unmodified to the pipeline
where
         <em>
          n
         </em>
         is the specified limit. For each input document,
outputs either one document (for the first
         <em>
          n
         </em>
         documents) or
zero documents (after the first
         <em>
          n
         </em>
         documents).
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/listSampledQueries/#mongodb-pipeline-pipe.-listSampledQueries">
          <code class="leafygreen-ui-1l06pbn">
           $listSampledQueries
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Lists sampled queries for all collections or a specific
collection.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/listSearchIndexes/#mongodb-pipeline-pipe.-listSearchIndexes">
          <code class="leafygreen-ui-1l06pbn">
           $listSearchIndexes
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns information about existing
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/atlas-search-overview/#fts-indexes" target="_self">
           <span>
            Atlas Search indexes
           </span>
          </a>
          on a specified
collection.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/listSessions/#mongodb-pipeline-pipe.-listSessions">
          <code class="leafygreen-ui-1l06pbn">
           $listSessions
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Lists all sessions that have been active long enough to
propagate to the
         <code class="leafygreen-ui-1l06pbn">
          system.sessions
         </code>
         collection.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/lookup/#mongodb-pipeline-pipe.-lookup">
          <code class="leafygreen-ui-1l06pbn">
           $lookup
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Performs a left outer join to another collection in the
         <em>
          same
         </em>
         database to filter in documents from the "joined"
collection for processing.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match">
          <code class="leafygreen-ui-1l06pbn">
           $match
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Filters the document stream to allow only matching documents
to pass unmodified into the next pipeline stage.
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match">
          <code class="leafygreen-ui-1l06pbn">
           $match
          </code>
         </a>
         uses standard MongoDB queries. For each
input document, outputs either one document (a match) or zero
documents (no match).
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge">
          <code class="leafygreen-ui-1l06pbn">
           $merge
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Writes the resulting documents of the aggregation pipeline to
a collection. The stage can incorporate (insert new
documents, merge documents, replace documents, keep existing
documents, fail the operation, process documents with a
custom update pipeline) the results into an output
collection. To use the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/merge/#mongodb-pipeline-pipe.-merge">
          <code class="leafygreen-ui-1l06pbn">
           $merge
          </code>
         </a>
         stage, it must be
the last stage in the pipeline.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
          <code class="leafygreen-ui-1l06pbn">
           $out
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Writes the resulting documents of the aggregation pipeline to
a collection. To use the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
          <code class="leafygreen-ui-1l06pbn">
           $out
          </code>
         </a>
         stage, it must be
the last stage in the pipeline.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/planCacheStats/#mongodb-pipeline-pipe.-planCacheStats">
          <code class="leafygreen-ui-1l06pbn">
           $planCacheStats
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/query-plans/#std-label-query-plans-query-optimization">
          plan cache
         </a>
         information for a
collection.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
          <code class="leafygreen-ui-1l06pbn">
           $project
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Reshapes each document in the stream, such as by adding new
fields or removing existing fields. For each input document,
outputs one document.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          See also
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset">
           <code class="leafygreen-ui-1l06pbn">
            $unset
           </code>
          </a>
          for removing existing fields.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/querySettings/#mongodb-pipeline-pipe.-querySettings">
          <code class="leafygreen-ui-1l06pbn">
           $querySettings
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns query settings previously added with
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/setQuerySettings/#mongodb-dbcommand-dbcmd.setQuerySettings">
           <code class="leafygreen-ui-1l06pbn">
            setQuerySettings
           </code>
           .
          </a>
         </p>
         <div>
          <p>
           <em>
            New
            <!-- -->
            in version
            <!-- -->
            8.0
           </em>
           .
          </p>
         </div>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/queryStats/#mongodb-pipeline-pipe.-queryStats">
          <code class="leafygreen-ui-1l06pbn">
           $queryStats
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns runtime statistics for recorded queries.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <strong class="css-4dei7l">
           WARNING:
          </strong>
          The
          <code class="leafygreen-ui-1l06pbn">
           $queryStats
          </code>
          aggregation stage is unsupported
and is not guaranteed to be stable in a future release. Don't build
functionality that relies on a specific output format of this stage,
since the output may change in a future release.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact">
          <code class="leafygreen-ui-1l06pbn">
           $redact
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Reshapes each document in the stream by restricting the
content for each document based on information stored in the
documents themselves. Incorporates the functionality of
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
          <code class="leafygreen-ui-1l06pbn">
           $project
          </code>
         </a>
         and
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/match/#mongodb-pipeline-pipe.-match">
          <code class="leafygreen-ui-1l06pbn">
           $match
          </code>
         </a>
         . Can be used to
implement field level redaction. For each input document,
outputs either one or zero documents.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceRoot/#mongodb-pipeline-pipe.-replaceRoot">
          <code class="leafygreen-ui-1l06pbn">
           $replaceRoot
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Replaces a document with the specified embedded document. The
operation replaces all existing fields in the input document,
including the
          <code class="leafygreen-ui-1l06pbn">
           _id
          </code>
          field. Specify a document embedded in
the input document to promote the embedded document to the
top level.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceWith/#mongodb-pipeline-pipe.-replaceWith">
           <code class="leafygreen-ui-1l06pbn">
            $replaceWith
           </code>
          </a>
          is an alias for
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceRoot/#mongodb-pipeline-pipe.-replaceRoot">
           <code class="leafygreen-ui-1l06pbn">
            $replaceRoot
           </code>
          </a>
          stage.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceWith/#mongodb-pipeline-pipe.-replaceWith">
          <code class="leafygreen-ui-1l06pbn">
           $replaceWith
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Replaces a document with the specified embedded document. The
operation replaces all existing fields in the input document,
including the
          <code class="leafygreen-ui-1l06pbn">
           _id
          </code>
          field. Specify a document embedded in
the input document to promote the embedded document to the
top level.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceWith/#mongodb-pipeline-pipe.-replaceWith">
           <code class="leafygreen-ui-1l06pbn">
            $replaceWith
           </code>
          </a>
          is an alias for
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceRoot/#mongodb-pipeline-pipe.-replaceRoot">
           <code class="leafygreen-ui-1l06pbn">
            $replaceRoot
           </code>
          </a>
          stage.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sample/#mongodb-pipeline-pipe.-sample">
          <code class="leafygreen-ui-1l06pbn">
           $sample
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Randomly selects the specified number of documents from its
input.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/search/#mongodb-pipeline-pipe.-search" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            $search
           </code>
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Performs a full-text search of the field or fields in an
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/" target="_self">
           <span>
            Atlas
           </span>
          </a>
          collection.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           $search
          </code>
          is only available for MongoDB Atlas clusters, and is not
available for self-managed deployments. To learn more, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/" target="_self">
           <span>
            Atlas Search Aggregation Pipeline Stages
            <!-- -->
            .
           </span>
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/searchMeta/#mongodb-pipeline-pipe.-searchMeta" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            $searchMeta
           </code>
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Returns different types of metadata result documents for the
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-search/" target="_self">
           <span>
            Atlas Search
           </span>
          </a>
          query against an
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/" target="_self">
           <span>
            Atlas
           </span>
          </a>
          collection.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           $searchMeta
          </code>
          is only available for MongoDB Atlas clusters,
and is not available for self-managed deployments. To learn
more, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/" target="_self">
           <span>
            Atlas Search Aggregation Pipeline Stages
            <!-- -->
            .
           </span>
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set">
          <code class="leafygreen-ui-1l06pbn">
           $set
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Adds new fields to documents. Similar to
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
           <code class="leafygreen-ui-1l06pbn">
            $project
           </code>
          </a>
          ,
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set">
           <code class="leafygreen-ui-1l06pbn">
            $set
           </code>
          </a>
          reshapes each
document in the stream; specifically, by adding new fields to
output documents that contain both the existing fields
from the input documents and the newly added fields.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set">
           <code class="leafygreen-ui-1l06pbn">
            $set
           </code>
          </a>
          is an alias for
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
           <code class="leafygreen-ui-1l06pbn">
            $addFields
           </code>
          </a>
          stage.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/setWindowFields/#mongodb-pipeline-pipe.-setWindowFields">
          <code class="leafygreen-ui-1l06pbn">
           $setWindowFields
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Groups documents into windows and applies one or more
operators to the documents in each window.
         </p>
         <div>
          <p>
           <em>
            New
            <!-- -->
            in version
            <!-- -->
            5.0
           </em>
           .
          </p>
         </div>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/skip/#mongodb-pipeline-pipe.-skip">
          <code class="leafygreen-ui-1l06pbn">
           $skip
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Skips the first
         <em>
          n
         </em>
         documents where
         <em>
          n
         </em>
         is the specified skip
number and passes the remaining documents unmodified to the
pipeline. For each input document, outputs either zero
documents (for the first
         <em>
          n
         </em>
         documents) or one document (if
after the first
         <em>
          n
         </em>
         documents).
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort">
          <code class="leafygreen-ui-1l06pbn">
           $sort
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Reorders the document stream by a specified sort key. Only
the order changes; the documents remain unmodified. For each
input document, outputs one document.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sortByCount/#mongodb-pipeline-pipe.-sortByCount">
          <code class="leafygreen-ui-1l06pbn">
           $sortByCount
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Groups incoming documents based on the value of a specified
expression, then computes the count of documents in each
distinct group.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unionWith/#mongodb-pipeline-pipe.-unionWith">
          <code class="leafygreen-ui-1l06pbn">
           $unionWith
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Performs a union of two collections; i.e. combines
pipeline results from two collections into a single
result set.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset">
          <code class="leafygreen-ui-1l06pbn">
           $unset
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Removes/excludes fields from documents.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset">
           <code class="leafygreen-ui-1l06pbn">
            $unset
           </code>
          </a>
          is an alias for
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
           <code class="leafygreen-ui-1l06pbn">
            $project
           </code>
          </a>
          stage
that removes fields.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unwind/#mongodb-pipeline-pipe.-unwind">
          <code class="leafygreen-ui-1l06pbn">
           $unwind
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Deconstructs an array field from the input documents to
output a document for
         <em>
          each
         </em>
         element. Each output document
replaces the array with an element value. For each input
document, outputs
         <em>
          n
         </em>
         documents where
         <em>
          n
         </em>
         is the number of
array elements and can be zero for an empty array.
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#mongodb-pipeline-pipe.-vectorSearch" target="_self">
          <span>
           <code class="leafygreen-ui-1l06pbn">
            $vectorSearch
           </code>
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <p class="leafygreen-ui-1kp3ins">
          Performs an
          <span class="leafygreen-ui-vm4wms" tabindex="0">
           ANN
          </span>
          or
          <span class="leafygreen-ui-vm4wms" tabindex="0">
           ENN
          </span>
          search on a
vector in the specified field of an
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/" target="_self">
           <span>
            Atlas
           </span>
          </a>
          collection.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           $vectorSearch
          </code>
          is only available for MongoDB Atlas clusters
running MongoDB v6.0.11 or higher, and is not available for
self-managed deployments.
         </p>
         <div>
          <p>
           <em>
            New
            <!-- -->
            in version
            <!-- -->
            7.0.2
           </em>
           .
          </p>
         </div>
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   For aggregation expression operators to use in the pipeline stages, see
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/#std-label-aggregation-pipeline-operators">
    Aggregation Operators
    <!-- -->
    .
   </a>
  </p>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   db.aggregate() Stages
   <a class="headerlink leafygreen-ui-1kepx47" href="#db.aggregate---stages" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="db.aggregate---stages">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   MongoDB also provides the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.aggregate/#mongodb-method-db.aggregate">
    <code class="leafygreen-ui-1l06pbn">
     db.aggregate()
    </code>
   </a>
   method:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.aggregate( [ { &lt;stage&gt; }, ... ] )","programmingLanguage":"JavaScript"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-1q4bxgx" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[ <!-- -->{ &lt;<!-- -->stage<!-- -->&gt; <!-- -->}<!-- -->, <!-- -->...<!-- --> ] )</td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   The following stages use the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.aggregate/#mongodb-method-db.aggregate">
    <code class="leafygreen-ui-1l06pbn">
     db.aggregate()
    </code>
   </a>
   method and not
the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.aggregate/#mongodb-method-db.collection.aggregate">
    <code class="leafygreen-ui-1l06pbn">
     db.collection.aggregate()
    </code>
   </a>
   method.
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:20%"/>
     <col style="width:80%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Stage
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Description
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/changeStream/#mongodb-pipeline-pipe.-changeStream">
          <code class="leafygreen-ui-1l06pbn">
           $changeStream
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns a
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/changeStreams/#std-label-changeStreams">
          Change Stream
         </a>
         cursor for the
collection.  This stage can only occur once in an aggregation
pipeline and it must occur as the first stage.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/currentOp/#mongodb-pipeline-pipe.-currentOp">
          <code class="leafygreen-ui-1l06pbn">
           $currentOp
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns information on active and/or dormant operations for
the MongoDB deployment.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/documents/#mongodb-pipeline-pipe.-documents">
          <code class="leafygreen-ui-1l06pbn">
           $documents
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Returns literal documents from input values.
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/listLocalSessions/#mongodb-pipeline-pipe.-listLocalSessions">
          <code class="leafygreen-ui-1l06pbn">
           $listLocalSessions
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Lists all active sessions recently in use on the currently
connected
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongos/#mongodb-binary-bin.mongos">
          <code class="leafygreen-ui-1l06pbn">
           mongos
          </code>
         </a>
         or
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/program/mongod/#mongodb-binary-bin.mongod">
          <code class="leafygreen-ui-1l06pbn">
           mongod
          </code>
         </a>
         instance. These sessions may have not yet propagated to the
         <code class="leafygreen-ui-1l06pbn">
          system.sessions
         </code>
         collection.
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Stages Available for Updates
   <a class="headerlink leafygreen-ui-1kepx47" href="#stages-available-for-updates" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="stages-available-for-updates">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   You can use the aggregation pipeline for updates in:
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Command
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         <code class="leafygreen-ui-1l06pbn">
          mongosh
         </code>
         Methods
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/findAndModify/#mongodb-dbcommand-dbcmd.findAndModify">
          <code class="leafygreen-ui-1l06pbn">
           findAndModify
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOneAndUpdate/#std-label-findOneAndUpdate-agg-pipeline">
            db.collection.findOneAndUpdate()
           </a>
          </div>
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findAndModify/#std-label-findAndModify-agg-pipeline">
            db.collection.findAndModify()
           </a>
          </div>
         </div>
        </div>
       </div>
      </td>
     </tr>
     <tr class="">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/command/update/#mongodb-dbcommand-dbcmd.update">
          <code class="leafygreen-ui-1l06pbn">
           update
          </code>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <div class="line-block">
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateOne/#std-label-updateOne-example-agg">
            db.collection.updateOne()
           </a>
          </div>
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.updateMany/#std-label-updateMany-example-agg">
            db.collection.updateMany()
           </a>
          </div>
         </div>
         <div class="line-block">
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.update/#std-label-example-bulk-find-update-agg">
            Bulk.find.update()
           </a>
          </div>
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.updateOne/#std-label-example-bulk-find-update-one-agg">
            Bulk.find.updateOne()
           </a>
          </div>
          <div class="line">
           <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Bulk.find.upsert/#std-label-bulk-find-upsert-update-agg-example">
            Bulk.find.upsert()
           </a>
          </div>
         </div>
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   For the updates, the pipeline can consist of the following stages:
  </p>
  <ul class="leafygreen-ui-rioki0">
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
      <code class="leafygreen-ui-1l06pbn">
       $addFields
      </code>
     </a>
     and its alias
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/set/#mongodb-pipeline-pipe.-set">
      <code class="leafygreen-ui-1l06pbn">
       $set
      </code>
     </a>
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
      <code class="leafygreen-ui-1l06pbn">
       $project
      </code>
     </a>
     and its alias
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/unset/#mongodb-pipeline-pipe.-unset">
      <code class="leafygreen-ui-1l06pbn">
       $unset
      </code>
     </a>
    </p>
   </li>
   <li class="leafygreen-ui-d7p7b6">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceRoot/#mongodb-pipeline-pipe.-replaceRoot">
      <code class="leafygreen-ui-1l06pbn">
       $replaceRoot
      </code>
     </a>
     and its alias
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/replaceWith/#mongodb-pipeline-pipe.-replaceWith">
      <code class="leafygreen-ui-1l06pbn">
       $replaceWith
      </code>
      .
     </a>
    </p>
   </li>
  </ul>
 </section>
</section>
